Build #159
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 7 * * *' | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
if: contains(github.event.commits[0].message, '[skip ci]') == false && | |
github.repository == 'roblox-csharp/types' && | |
github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 9.0.x | |
- name: Configure Git | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "noreply@github.com" | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build -c Release --no-restore | |
- name: Install xmlstarlet | |
run: sudo apt-get update && sudo apt-get install -y xmlstarlet | |
- name: Generate Files | |
run: TypeGenerator/bin/Release/net9.0/TypeGenerator -o ./RobloxTypes | |
- name: Push Generated Files | |
run: | | |
git add -A | |
if ! git diff-index --quiet HEAD --; then | |
echo "Generated files changed!" | |
git commit -m "feat: update generated files [skip ci]" | |
git push https://R-unic:${{ secrets.github_token }}@github.com/roblox-csharp/types.git HEAD:master | |
fi | |
- name: Copy Files to Deploy Branch and Publish | |
run: | | |
cd .. | |
git clone --depth=50 --branch=deploy https://R-unic:${{ secrets.github_token }}@github.com/roblox-csharp/types.git deploy | |
mkdir -p deploy/Include | |
rm -rf deploy/Include/* | |
cp -r types/RobloxTypes/* deploy/Include | |
cp types/RobloxTypes/Generated/PluginSecurity.cs deploy/PluginSecurity.cs | |
cp types/RobloxTypes/README.md deploy/README.md | |
cd deploy | |
git add -A | |
if ! git diff-index --quiet HEAD --; then | |
echo "Deploy changed!" | |
if [ "$GITHUB_EVENT_NAME" == "push" ]; then | |
git commit -m "build: manual update" | |
else | |
git commit -m "build: automatic update" | |
fi | |
# set -x # Debug mode | |
# Extract current version from .csproj | |
CURRENT_VERSION=$(xmlstarlet sel -t -v "//Project/PropertyGroup/Version" ./Include/RobloxTypes.csproj) | |
echo "Current version: $CURRENT_VERSION" | |
# Increment patch version | |
IFS='.' read -r -a version_parts <<< "$CURRENT_VERSION" | |
PATCH_VERSION=$((version_parts[2] + 1)) | |
echo "Patch version: $PATCH_VERSION" | |
NEW_VERSION="${version_parts[0]}.${version_parts[1]}.$PATCH_VERSION" | |
echo "New version: $NEW_VERSION" | |
# Update version in .csproj | |
xmlstarlet ed -L -u "//Project/PropertyGroup/Version" -v "$NEW_VERSION" ./Include/RobloxTypes.csproj | |
# Commit version change | |
git add ./Include/RobloxTypes.csproj | |
git commit -m "build: bump version to $NEW_VERSION" | |
git push https://R-unic:${{ secrets.github_token }}@github.com/roblox-csharp/types.git HEAD:deploy | |
# Add GitHub source to NuGet | |
dotnet nuget add source --username roblox-csharp --password ${{ secrets.github_token }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/roblox-csharp/index.json" | |
# Package the project | |
dotnet pack ./Include/RobloxTypes.csproj --configuration Release | |
# Find and publish the latest package | |
PACKAGE_PATH=./Include/bin/Release/RobloxCS.Types.$NEW_VERSION.nupkg | |
echo "Publishing package: $PACKAGE_PATH" | |
dotnet nuget push "$PACKAGE_PATH" --api-key ${{ secrets.github_token }} --source "github" --skip-duplicate | |
fi | |
- name: Send Build Failure Notification | |
uses: rjstone/discord-webhook-notify@v1 | |
if: failure() | |
with: | |
severity: error | |
details: Build Failed! | |
webhookUrl: ${{ secrets.WEBHOOK_URL }} |