test(ci): exercise stable release pipeline [DO NOT MERGE] #321
Workflow file for this run
This file contains hidden or 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 and release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| - "release/**" | |
| pull_request: | |
| branches: | |
| - main | |
| - dev | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| windows: | |
| runs-on: windows-2022 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Prepare environment variables | |
| shell: pwsh | |
| run: | | |
| $commitHash = "${{ github.sha }}".Substring(0, 8) | |
| $appVersion = (Select-String -Path "loader\Program.cs" -Pattern 'VERSION = "(.+)"' -AllMatches).Matches.Groups[1].Value | |
| $channel = switch ("${{ github.ref_name }}") { | |
| "main" { "stable" } | |
| "release/stable-test-do-not-merge" { "stable" } | |
| "dev" { "dev" } | |
| default { "ci" } | |
| } | |
| "COMMIT_HASH=$commitHash" >> $env:GITHUB_ENV | |
| "APP_VERSION=$appVersion" >> $env:GITHUB_ENV | |
| "BUILD_CHANNEL=$channel" >> $env:GITHUB_ENV | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v2 | |
| with: | |
| msbuild-architecture: x64 | |
| - name: Install .NET 4.7.2 SDK | |
| shell: cmd | |
| run: | | |
| mkdir downloads && cd downloads | |
| curl -LJO https://download.microsoft.com/download/7/1/7/71795fde-1cca-41b0-b495-00b1ab656994/NDP472-DevPack-ENU.exe | |
| start /wait "" "NDP472-DevPack-ENU.exe" /q | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| run_install: | | |
| - recursive: true | |
| - name: Build preload plugins | |
| working-directory: plugins | |
| run: pnpm build | |
| - name: Build solution | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force bin | |
| Set-Content bin/version "${{ env.APP_VERSION }}+${{ env.COMMIT_HASH }}+${{ env.BUILD_CHANNEL }}" -NoNewline | |
| msbuild pengu.sln /t:Restore,Build /m /p:Configuration=Release /p:Platform=x64 | |
| - name: Test update-channel logic | |
| shell: pwsh | |
| run: | | |
| $test = Start-Process ".\bin\Pengu Loader.exe" -ArgumentList "--self-test-updater" -Wait -PassThru | |
| if ($test.ExitCode -ne 0) { throw "Updater self-test failed." } | |
| - name: Upload Windows build | |
| uses: actions/upload-artifact@v4 | |
| id: windows-artifact | |
| with: | |
| name: pengu-v${{ env.APP_VERSION }}-${{ env.COMMIT_HASH }}-${{ env.BUILD_CHANNEL }}-windows | |
| path: | | |
| bin/*.exe | |
| bin/*.dll | |
| bin/version | |
| - name: Package dev release | |
| if: ${{ github.event_name == 'push' && github.ref_name == 'dev' }} | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force dist | |
| Compress-Archive -Path bin/*.exe,bin/*.dll,bin/version -DestinationPath dist/pengu-v${{ env.APP_VERSION }}-dev-windows.zip -Force | |
| - name: Upload dev release files | |
| if: ${{ github.event_name == 'push' && github.ref_name == 'dev' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-windows | |
| path: dist/* | |
| - name: Remove unsigned output | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| shell: pwsh | |
| run: Remove-Item bin/* -Recurse -Force | |
| - name: Sign stable build | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| uses: signpath/github-action-submit-signing-request@v1 | |
| with: | |
| api-token: ${{ secrets.SIGNPATH_API_TOKEN }} | |
| organization-id: ${{ secrets.SIGNPATH_ORG_ID }} | |
| project-slug: PenguLoader | |
| signing-policy-slug: release-signing | |
| artifact-configuration-slug: zipped-app | |
| github-artifact-id: ${{ steps.windows-artifact.outputs.artifact-id }} | |
| wait-for-completion: true | |
| output-artifact-directory: bin | |
| - name: Make stable installer and portable archive | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force bin-signed | |
| Set-Content bin/version "${{ env.APP_VERSION }}+${{ env.COMMIT_HASH }}+stable" -NoNewline | |
| Compress-Archive -Path bin/* -DestinationPath bin-signed/pengu-v${{ env.APP_VERSION }}-stable-windows.zip -Force | |
| & "$env:ProgramFiles (x86)\Inno Setup 6\iscc.exe" /O"bin" /F"pengu-v${{ env.APP_VERSION }}-stable-setup" scripts\setup.iss | |
| - name: Upload stable installer for signing | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| uses: actions/upload-artifact@v4 | |
| id: installer-artifact | |
| with: | |
| name: stable-installer | |
| path: bin/pengu-*-setup.exe | |
| - name: Sign stable installer | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| uses: signpath/github-action-submit-signing-request@v1 | |
| with: | |
| api-token: ${{ secrets.SIGNPATH_API_TOKEN }} | |
| organization-id: ${{ secrets.SIGNPATH_ORG_ID }} | |
| project-slug: PenguLoader | |
| signing-policy-slug: release-signing | |
| artifact-configuration-slug: zipped-installer | |
| github-artifact-id: ${{ steps.installer-artifact.outputs.artifact-id }} | |
| wait-for-completion: true | |
| output-artifact-directory: bin-signed | |
| - name: Upload stable release files | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-windows | |
| path: bin-signed/* | |
| macos: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Prepare environment variables | |
| run: | | |
| case "$GITHUB_REF_NAME" in | |
| main|release/stable-test-do-not-merge) channel=stable ;; | |
| dev) channel=dev ;; | |
| *) channel=ci ;; | |
| esac | |
| echo "COMMIT_HASH=$(git rev-parse --short=8 HEAD)" >> "$GITHUB_ENV" | |
| echo "APP_VERSION=$(sed -n 's/.*VERSION = "\([^" ]*\)".*/\1/p' loader/Program.cs)" >> "$GITHUB_ENV" | |
| echo "BUILD_CHANNEL=$channel" >> "$GITHUB_ENV" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| run_install: | | |
| - recursive: true | |
| - name: Build preload plugins | |
| working-directory: plugins | |
| run: pnpm build | |
| - name: Build macOS core | |
| run: | | |
| make release | |
| echo "${{ env.APP_VERSION }}+${{ env.COMMIT_HASH }}+${{ env.BUILD_CHANNEL }}" > bin/version | |
| - name: Upload macOS core | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pengu-v${{ env.APP_VERSION }}-${{ env.COMMIT_HASH }}-${{ env.BUILD_CHANNEL }}-macos-core | |
| path: | | |
| bin/core.dylib | |
| bin/insert_dylib | |
| bin/version | |
| - name: Package macOS release | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| run: | | |
| mkdir dist | |
| zip -j "dist/pengu-v${{ env.APP_VERSION }}-${{ env.BUILD_CHANNEL }}-macos-core.zip" bin/core.dylib bin/insert_dylib bin/version | |
| - name: Upload macOS release files | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-macos | |
| path: dist/* | |
| release: | |
| if: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'release/stable-test-do-not-merge') }} | |
| needs: | |
| - windows | |
| - macos | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Download release files | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: release-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| version=$(sed -n 's/.*VERSION = "\([^" ]*\)".*/\1/p' loader/Program.cs) | |
| channel=$([ "$GITHUB_REF_NAME" = main ] && echo stable || echo dev) | |
| tag="v${version}-${channel}.${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}" | |
| if [ "$GITHUB_REF_NAME" = release/stable-test-do-not-merge ]; then | |
| channel=stable | |
| tag="v${version}-stable-test.${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}" | |
| fi | |
| if [ "$channel" = stable ]; then | |
| previous=$(gh api "repos/$GITHUB_REPOSITORY/releases?per_page=100" --jq 'map(select(.draft == false and .prerelease == false))[0].tag_name // empty') | |
| if [ "$GITHUB_REF_NAME" = release/stable-test-do-not-merge ]; then | |
| title="Pengu Loader v${version} Stable Test (DO NOT USE)" | |
| channel_flags=(--draft --latest=false) | |
| else | |
| title="Pengu Loader v${version} Stable" | |
| channel_flags=(--latest) | |
| fi | |
| else | |
| previous=$(gh api "repos/$GITHUB_REPOSITORY/releases?per_page=100" --jq 'map(select(.draft == false and .prerelease == true))[0].tag_name // empty') | |
| if [ -z "$previous" ]; then | |
| previous=$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" --jq '.tag_name') | |
| fi | |
| title="Pengu Loader v${version} Development" | |
| channel_flags=(--prerelease --latest=false) | |
| fi | |
| notes_flags=(--generate-notes) | |
| if [ -n "$previous" ]; then | |
| notes_flags+=(--notes-start-tag "$previous") | |
| fi | |
| gh release create "$tag" dist/* \ | |
| --target "$GITHUB_SHA" \ | |
| --title "$title" \ | |
| "${notes_flags[@]}" \ | |
| "${channel_flags[@]}" |