Skip to content

Commit df53363

Browse files
committed
ci: add release workflow (package + deploy to NuGet/GitHub)
1 parent fbc3792 commit df53363

1 file changed

Lines changed: 222 additions & 0 deletions

File tree

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)