|
| 1 | +name: Release Launcher |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + sign: |
| 7 | + description: Code sign packages |
| 8 | + default: true |
| 9 | + type: boolean |
| 10 | + deploy: |
| 11 | + description: Deploy to NuGet.org |
| 12 | + default: false |
| 13 | + type: boolean |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: release-launcher-${{ github.ref }} |
| 17 | + cancel-in-progress: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + # |
| 21 | + # Validate inputs and permissions |
| 22 | + # |
| 23 | + Validate: |
| 24 | + name: Validate |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Check deploy requires signing |
| 28 | + if: ${{ inputs.deploy && !inputs.sign }} |
| 29 | + run: | |
| 30 | + echo "::error::Cannot deploy unsigned packages. Enable 'sign' to deploy." |
| 31 | + exit 1 |
| 32 | +
|
| 33 | + - name: Check release permissions |
| 34 | + if: ${{ inputs.sign || inputs.deploy }} |
| 35 | + env: |
| 36 | + GH_TOKEN: ${{ secrets.GH_PAT }} |
| 37 | + run: | |
| 38 | + ORG=$(echo "${{ github.repository }}" | cut -d/ -f1) |
| 39 | + TEAM="stride-release-managers" |
| 40 | + USER="${{ github.actor }}" |
| 41 | + STATUS=$(gh api "orgs/$ORG/teams/$TEAM/memberships/$USER" --silent 2>&1 && echo "ok" || echo "fail") |
| 42 | + if [ "$STATUS" = "fail" ]; then |
| 43 | + echo "::error::User $USER is not a member of $ORG/$TEAM. Sign/deploy requires stride-release-managers team membership." |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | +
|
| 47 | + # |
| 48 | + # Build, package and optionally deploy the launcher |
| 49 | + # |
| 50 | + Package: |
| 51 | + name: Package Launcher |
| 52 | + needs: Validate |
| 53 | + runs-on: windows-latest |
| 54 | + environment: production |
| 55 | + outputs: |
| 56 | + version: ${{ steps.version.outputs.version }} |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + with: |
| 60 | + lfs: true |
| 61 | + fetch-depth: 0 |
| 62 | + |
| 63 | + - uses: actions/setup-dotnet@v4 |
| 64 | + with: |
| 65 | + dotnet-version: | |
| 66 | + 6.0.x |
| 67 | + 10.0.x |
| 68 | +
|
| 69 | + - uses: microsoft/setup-msbuild@v2 |
| 70 | + |
| 71 | + - name: Install Advanced Installer |
| 72 | + shell: pwsh |
| 73 | + run: | |
| 74 | + Invoke-WebRequest -Uri "https://www.advancedinstaller.com/downloads/22.0/advinst.msi" -OutFile advinst.msi |
| 75 | + msiexec /i advinst.msi /qn ADDLOCAL=ALL | Out-Null |
| 76 | + if ("${{ secrets.ADVINST_LICENSE_KEY }}" -ne "") { |
| 77 | + & "${env:ProgramFiles(x86)}\Caphyon\Advanced Installer 22.0\bin\x86\AdvancedInstaller.com" /register "${{ secrets.ADVINST_LICENSE_KEY }}" |
| 78 | + } |
| 79 | +
|
| 80 | + - name: Build and package launcher |
| 81 | + shell: pwsh |
| 82 | + run: | |
| 83 | + msbuild build\Stride.build ` |
| 84 | + /t:FullBuildLauncher ` |
| 85 | + /bl /m /nr:false ` |
| 86 | + /p:StrideSign=${{ inputs.sign }} |
| 87 | + env: |
| 88 | + StrideSignTenantId: ${{ secrets.STRIDE_SIGN_TENANT_ID }} |
| 89 | + StrideSignClientId: ${{ secrets.STRIDE_SIGN_CLIENT_ID }} |
| 90 | + StrideSignClientSecret: ${{ secrets.STRIDE_SIGN_CLIENT_SECRET }} |
| 91 | + StrideSignKeyVaultCertificate: ${{ secrets.STRIDE_SIGN_KEYVAULT_CERTIFICATE }} |
| 92 | + StrideSignKeyVaultName: ${{ secrets.STRIDE_SIGN_KEYVAULT_NAME }} |
| 93 | + |
| 94 | + - name: Get version |
| 95 | + id: version |
| 96 | + shell: pwsh |
| 97 | + run: | |
| 98 | + $nupkg = Get-ChildItem -Path bin/launcher -Filter "*.nupkg" | Select-Object -First 1 |
| 99 | + if ($nupkg -and $nupkg.BaseName -match '\.(\d+\.\d+\.\d+.*)$') { |
| 100 | + echo "version=$($Matches[1])" >> $env:GITHUB_OUTPUT |
| 101 | + } |
| 102 | +
|
| 103 | + - name: Upload launcher artifacts |
| 104 | + uses: actions/upload-artifact@v4 |
| 105 | + with: |
| 106 | + name: launcher |
| 107 | + path: | |
| 108 | + bin/launcher/*.nupkg |
| 109 | + bin/launcher/*.exe |
| 110 | + retention-days: 30 |
| 111 | + |
| 112 | + Deploy: |
| 113 | + name: Deploy Launcher |
| 114 | + if: ${{ inputs.deploy && inputs.sign }} |
| 115 | + needs: Package |
| 116 | + runs-on: ubuntu-latest |
| 117 | + steps: |
| 118 | + - uses: actions/setup-dotnet@v4 |
| 119 | + with: |
| 120 | + dotnet-version: 10.0.x |
| 121 | + |
| 122 | + - name: Download launcher artifacts |
| 123 | + uses: actions/download-artifact@v4 |
| 124 | + with: |
| 125 | + name: launcher |
| 126 | + path: bin/launcher |
| 127 | + |
| 128 | + - name: Push to NuGet |
| 129 | + shell: pwsh |
| 130 | + run: | |
| 131 | + Get-ChildItem -Path bin/launcher -Filter "*.nupkg" | ForEach-Object { |
| 132 | + echo "Pushing $($_.Name)..." |
| 133 | + dotnet nuget push $_.FullName --api-key $env:STRIDE_NUGET_API_KEY --source "https://api.nuget.org/v3/index.json" --skip-duplicate |
| 134 | + } |
| 135 | + env: |
| 136 | + STRIDE_NUGET_API_KEY: ${{ secrets.STRIDE_NUGET_API_KEY }} |
| 137 | + |
| 138 | + - name: Create GitHub Release |
| 139 | + if: ${{ needs.Package.outputs.version != '' }} |
| 140 | + uses: softprops/action-gh-release@v2 |
| 141 | + with: |
| 142 | + tag_name: launcher/${{ needs.Package.outputs.version }} |
| 143 | + name: Stride Launcher ${{ needs.Package.outputs.version }} |
| 144 | + files: bin/launcher/*.exe |
| 145 | + prerelease: ${{ contains(needs.Package.outputs.version, '-') }} |
| 146 | + generate_release_notes: true |
0 commit comments