|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: #temporary to register in github |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + platforms: |
| 8 | + description: Platforms to build |
| 9 | + default: 'Windows' |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - Windows |
| 13 | + - 'Windows;Linux' |
| 14 | + - 'Windows;Android' |
| 15 | + - 'Windows;iOS' |
| 16 | + - 'Windows;Linux;Android;iOS' |
| 17 | + sign: |
| 18 | + description: Code sign packages |
| 19 | + default: false |
| 20 | + type: boolean |
| 21 | + build-prerequisites-installer: |
| 22 | + description: Build prerequisites installer (requires Advanced Installer) |
| 23 | + default: false |
| 24 | + type: boolean |
| 25 | + deploy: |
| 26 | + description: Deploy to NuGet.org and create GitHub Release |
| 27 | + default: false |
| 28 | + type: boolean |
| 29 | + |
| 30 | +concurrency: |
| 31 | + group: release-${{ github.ref }} |
| 32 | + cancel-in-progress: false |
| 33 | + |
| 34 | +jobs: |
| 35 | + # |
| 36 | + # Build and package |
| 37 | + # |
| 38 | + Package: |
| 39 | + name: Package (${{ inputs.platforms }}) |
| 40 | + runs-on: windows-latest |
| 41 | + outputs: |
| 42 | + version: ${{ steps.version.outputs.version }} |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + lfs: true |
| 47 | + fetch-depth: 0 # Full history needed for GitVersioning |
| 48 | + |
| 49 | + - uses: actions/setup-dotnet@v4 |
| 50 | + with: |
| 51 | + # 6.0.x required by deps/Gettext.Net/GNU.Gettext.Msgfmt.exe (see #3113) |
| 52 | + dotnet-version: | |
| 53 | + 6.0.x |
| 54 | + 10.0.x |
| 55 | +
|
| 56 | + - name: Build Package |
| 57 | + run: | |
| 58 | + dotnet msbuild build\Stride.build ` |
| 59 | + /t:Package ` |
| 60 | + /bl /m /nr:false ` |
| 61 | + /p:StridePlatforms="${{ inputs.platforms }}" ` |
| 62 | + /p:StrideGraphicsApiDependentBuildAll=true ` |
| 63 | + /p:StrideSign=${{ inputs.sign }} ` |
| 64 | + /p:StrideBuildPrerequisitesInstaller=${{ inputs.build-prerequisites-installer }} ` |
| 65 | + /p:StrideNativeBuildMode=Clang |
| 66 | + env: |
| 67 | + StrideDisableAssetCompilerExecServerProxy: true |
| 68 | + StrideSignTenantId: ${{ inputs.sign && secrets.STRIDE_SIGN_TENANT_ID || '' }} |
| 69 | + StrideSignClientId: ${{ inputs.sign && secrets.STRIDE_SIGN_CLIENT_ID || '' }} |
| 70 | + StrideSignClientSecret: ${{ inputs.sign && secrets.STRIDE_SIGN_CLIENT_SECRET || '' }} |
| 71 | + StrideSignKeyVaultCertificate: ${{ inputs.sign && secrets.STRIDE_SIGN_KEYVAULT_CERTIFICATE || '' }} |
| 72 | + StrideSignKeyVaultName: ${{ inputs.sign && secrets.STRIDE_SIGN_KEYVAULT_NAME || '' }} |
| 73 | + |
| 74 | + - name: Detect version |
| 75 | + id: version |
| 76 | + shell: pwsh |
| 77 | + run: | |
| 78 | + $pkg = Get-ChildItem -Path bin/packages -Filter "Stride.Core.*.nupkg" | Select-Object -First 1 |
| 79 | + if ($pkg) { |
| 80 | + $version = $pkg.Name -replace 'Stride\.Core\.(.*?)\.nupkg','$1' |
| 81 | + echo "version=$version" >> $env:GITHUB_OUTPUT |
| 82 | + echo "::notice::Package version: $version" |
| 83 | + } else { |
| 84 | + echo "::error::No Stride.Core package found" |
| 85 | + exit 1 |
| 86 | + } |
| 87 | +
|
| 88 | + - name: Upload NuGet packages |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: packages |
| 92 | + path: bin/packages/*.nupkg |
| 93 | + if-no-files-found: error |
| 94 | + |
| 95 | + - name: Upload VSIX packages |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + if: always() |
| 98 | + with: |
| 99 | + name: vsix |
| 100 | + path: bin/vsix/*.nupkg |
| 101 | + if-no-files-found: ignore |
| 102 | + |
| 103 | + - name: Upload build log |
| 104 | + uses: actions/upload-artifact@v4 |
| 105 | + if: ${{ always() && !inputs.sign }} |
| 106 | + with: |
| 107 | + name: build-log |
| 108 | + path: msbuild.binlog |
| 109 | + if-no-files-found: ignore |
| 110 | + |
| 111 | + # |
| 112 | + # Deploy to NuGet.org and create GitHub Release |
| 113 | + # |
| 114 | + Deploy: |
| 115 | + name: Deploy ${{ needs.Package.outputs.version }} |
| 116 | + if: ${{ inputs.deploy }} |
| 117 | + needs: Package |
| 118 | + runs-on: ubuntu-latest # NuGet push doesn't need Windows |
| 119 | + environment: production # Requires manual approval in GitHub settings |
| 120 | + permissions: |
| 121 | + contents: write |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v4 |
| 124 | + with: |
| 125 | + fetch-depth: 0 |
| 126 | + |
| 127 | + - uses: actions/setup-dotnet@v4 |
| 128 | + with: |
| 129 | + dotnet-version: '10.0.x' |
| 130 | + |
| 131 | + - name: Download packages |
| 132 | + uses: actions/download-artifact@v4 |
| 133 | + with: |
| 134 | + name: packages |
| 135 | + path: bin/packages |
| 136 | + |
| 137 | + - name: Download VSIX |
| 138 | + uses: actions/download-artifact@v4 |
| 139 | + with: |
| 140 | + name: vsix |
| 141 | + path: bin/vsix |
| 142 | + continue-on-error: true # VSIX may not exist |
| 143 | + |
| 144 | + - name: List packages |
| 145 | + shell: pwsh |
| 146 | + run: | |
| 147 | + echo "## Packages to deploy" >> $env:GITHUB_STEP_SUMMARY |
| 148 | + echo '```' >> $env:GITHUB_STEP_SUMMARY |
| 149 | + Get-ChildItem -Path bin -Recurse -Filter "*.nupkg" | ForEach-Object { |
| 150 | + echo "$($_.Name)" >> $env:GITHUB_STEP_SUMMARY |
| 151 | + } |
| 152 | + echo '```' >> $env:GITHUB_STEP_SUMMARY |
| 153 | +
|
| 154 | + - name: Push NuGet packages |
| 155 | + shell: pwsh |
| 156 | + run: | |
| 157 | + $packages = Get-ChildItem -Path bin/packages -Filter "*.nupkg" |
| 158 | + $main = $packages | Where-Object { $_.Name -notmatch 'GameStudio' -and $_.Name -notmatch 'Samples\.Templates' } |
| 159 | + $samples = $packages | Where-Object { $_.Name -match 'Samples\.Templates' } |
| 160 | + $gameStudio = $packages | Where-Object { $_.Name -match 'GameStudio' } |
| 161 | +
|
| 162 | + echo "::group::Pushing main packages ($($main.Count))" |
| 163 | + foreach ($pkg in $main) { |
| 164 | + echo "Pushing $($pkg.Name)..." |
| 165 | + dotnet nuget push $pkg.FullName --api-key $env:NUGET_API_KEY --source "https://api.nuget.org/v3/index.json" --timeout 1800 --skip-duplicate |
| 166 | + } |
| 167 | + echo "::endgroup::" |
| 168 | +
|
| 169 | + if ($samples) { |
| 170 | + echo "::group::Pushing Samples.Templates" |
| 171 | + foreach ($pkg in $samples) { |
| 172 | + dotnet nuget push $pkg.FullName --api-key $env:NUGET_API_KEY --source "https://api.nuget.org/v3/index.json" --timeout 1800 --skip-duplicate |
| 173 | + } |
| 174 | + echo "::endgroup::" |
| 175 | + } |
| 176 | +
|
| 177 | + if ($gameStudio) { |
| 178 | + echo "::group::Pushing GameStudio (last, so dependencies are already available)" |
| 179 | + foreach ($pkg in $gameStudio) { |
| 180 | + dotnet nuget push $pkg.FullName --api-key $env:NUGET_API_KEY --source "https://api.nuget.org/v3/index.json" --timeout 1800 |
| 181 | + } |
| 182 | + echo "::endgroup::" |
| 183 | + } |
| 184 | + env: |
| 185 | + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
| 186 | + |
| 187 | + - name: Push VSIX packages |
| 188 | + if: ${{ hashFiles('bin/vsix/*.nupkg') != '' }} |
| 189 | + shell: pwsh |
| 190 | + run: | |
| 191 | + Get-ChildItem -Path bin/vsix -Filter "*.nupkg" | ForEach-Object { |
| 192 | + echo "Pushing $($_.Name)..." |
| 193 | + dotnet nuget push $_.FullName --api-key $env:NUGET_API_KEY --source "https://api.nuget.org/v3/index.json" |
| 194 | + } |
| 195 | + env: |
| 196 | + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |
| 197 | + |
| 198 | + - name: Tag release |
| 199 | + run: | |
| 200 | + if git rev-parse "releases/${{ needs.Package.outputs.version }}" >/dev/null 2>&1; then |
| 201 | + echo "Tag releases/${{ needs.Package.outputs.version }} already exists, skipping" |
| 202 | + else |
| 203 | + git tag "releases/${{ needs.Package.outputs.version }}" |
| 204 | + git push origin "releases/${{ needs.Package.outputs.version }}" |
| 205 | + fi |
| 206 | +
|
| 207 | + - name: Create GitHub Release |
| 208 | + run: | |
| 209 | + gh release create "releases/${{ needs.Package.outputs.version }}" \ |
| 210 | + --title "Stride ${{ needs.Package.outputs.version }}" \ |
| 211 | + --generate-notes \ |
| 212 | + bin/packages/*.nupkg |
| 213 | + env: |
| 214 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments