Skip to content

Commit 26aedc3

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

1 file changed

Lines changed: 223 additions & 0 deletions

File tree

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)