Skip to content

Commit ca955cc

Browse files
committed
feat(workflow): add windows release pipeline
1 parent 90bfcdc commit ca955cc

4 files changed

Lines changed: 433 additions & 0 deletions

File tree

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
name: Windows Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
description: Git tag to publish
8+
required: true
9+
type: string
10+
prerelease:
11+
description: Pre-release
12+
required: true
13+
type: boolean
14+
default: false
15+
include_pdb:
16+
description: Include PDB files in the publish output
17+
required: true
18+
type: boolean
19+
default: false
20+
21+
permissions:
22+
contents: write
23+
24+
jobs:
25+
publish:
26+
runs-on: windows-latest
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- rid: win-x64
32+
family: windows
33+
architecture: x64
34+
include_wpf: true
35+
archive_ext: zip
36+
- rid: win-x86
37+
family: windows
38+
architecture: x86
39+
include_wpf: true
40+
archive_ext: zip
41+
- rid: win-arm64
42+
family: windows
43+
architecture: arm64
44+
include_wpf: true
45+
archive_ext: zip
46+
- rid: linux-x64
47+
family: linux
48+
architecture: x64
49+
include_wpf: false
50+
archive_ext: tar.gz
51+
- rid: linux-arm64
52+
family: linux
53+
architecture: arm64
54+
include_wpf: false
55+
archive_ext: tar.gz
56+
- rid: osx-x64
57+
family: macos
58+
architecture: x64
59+
include_wpf: false
60+
archive_ext: tar.gz
61+
- rid: osx-arm64
62+
family: macos
63+
architecture: arm64
64+
include_wpf: false
65+
archive_ext: tar.gz
66+
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v4
70+
71+
- name: Setup .NET
72+
uses: actions/setup-dotnet@v4
73+
with:
74+
dotnet-version: '10.0.x'
75+
76+
- name: Restore project
77+
run: dotnet restore src/MCServerLauncher.Daemon/MCServerLauncher.Daemon.csproj
78+
79+
- name: Restore WPF project
80+
if: matrix.include_wpf
81+
run: dotnet restore src/MCServerLauncher.WPF/MCServerLauncher.WPF.csproj
82+
83+
- name: Publish packages
84+
shell: pwsh
85+
run: |
86+
$publishRoot = Join-Path $env:GITHUB_WORKSPACE 'artifacts'
87+
$includePdb = if ('${{ inputs.include_pdb }}' -eq 'true') { 'true' } else { 'false' }
88+
$packageModes = @(
89+
@{ name = 'self-contained'; selfContained = 'true'; suffix = 'sc' },
90+
@{ name = 'framework-dependent'; selfContained = 'false'; suffix = 'fdd' }
91+
)
92+
93+
foreach ($mode in $packageModes) {
94+
$packageBase = "mcsl-future-${{ matrix.rid }}-$($mode.suffix)"
95+
$packageDir = Join-Path $publishRoot $packageBase
96+
$metadataDir = Join-Path $publishRoot 'metadata'
97+
$daemonPublishDir = Join-Path $packageDir 'daemon'
98+
$wpfPublishDir = Join-Path $packageDir 'wpf'
99+
100+
New-Item -ItemType Directory -Force -Path $daemonPublishDir | Out-Null
101+
New-Item -ItemType Directory -Force -Path $metadataDir | Out-Null
102+
103+
$daemonArgs = @(
104+
'publish',
105+
'src/MCServerLauncher.Daemon/MCServerLauncher.Daemon.csproj',
106+
'-c', 'Release',
107+
'-r', '${{ matrix.rid }}',
108+
'--self-contained', $mode.selfContained,
109+
'-o', $daemonPublishDir
110+
)
111+
112+
if ($includePdb -ne 'true') {
113+
$daemonArgs += '-p:DebugType=None'
114+
$daemonArgs += '-p:DebugSymbols=false'
115+
}
116+
117+
dotnet @daemonArgs
118+
119+
$contents = @('daemon')
120+
121+
if ('${{ matrix.include_wpf }}' -eq 'true') {
122+
New-Item -ItemType Directory -Force -Path $wpfPublishDir | Out-Null
123+
124+
$wpfArgs = @(
125+
'publish',
126+
'src/MCServerLauncher.WPF/MCServerLauncher.WPF.csproj',
127+
'-c', 'Release',
128+
'-r', '${{ matrix.rid }}',
129+
'--self-contained', $mode.selfContained,
130+
'-o', $wpfPublishDir
131+
)
132+
133+
if ($includePdb -ne 'true') {
134+
$wpfArgs += '-p:DebugType=None'
135+
$wpfArgs += '-p:DebugSymbols=false'
136+
}
137+
138+
dotnet @wpfArgs
139+
$contents += 'wpf'
140+
}
141+
142+
$archiveBase = $packageBase
143+
$archivePath = Join-Path $publishRoot "$archiveBase.$('${{ matrix.archive_ext }}')"
144+
145+
if (Test-Path $archivePath) { Remove-Item $archivePath -Force }
146+
147+
if ('${{ matrix.archive_ext }}' -eq 'zip') {
148+
Compress-Archive -Path (Join-Path $packageDir '*') -DestinationPath $archivePath -Force
149+
}
150+
else {
151+
tar -czf $archivePath -C $packageDir .
152+
}
153+
154+
$metadata = [ordered]@{
155+
rid = '${{ matrix.rid }}'
156+
family = '${{ matrix.family }}'
157+
architecture = '${{ matrix.architecture }}'
158+
mode = $mode.name
159+
archiveName = [System.IO.Path]::GetFileName($archivePath)
160+
archiveType = '${{ matrix.archive_ext }}'
161+
contents = $contents
162+
}
163+
164+
$metadata | ConvertTo-Json -Depth 3 | Set-Content -Path (Join-Path $metadataDir "$archiveBase.json") -Encoding utf8
165+
}
166+
167+
- name: Upload artifacts
168+
uses: actions/upload-artifact@v4
169+
with:
170+
name: ${{ matrix.rid }}
171+
path: |
172+
artifacts/**/*.zip
173+
artifacts/**/*.tar.gz
174+
artifacts/metadata/*.json
175+
if-no-files-found: error
176+
177+
release:
178+
needs: publish
179+
runs-on: windows-latest
180+
steps:
181+
- name: Checkout code
182+
uses: actions/checkout@v4
183+
184+
- name: Download artifacts
185+
uses: actions/download-artifact@v4
186+
with:
187+
path: artifacts
188+
189+
- name: Build release body
190+
shell: pwsh
191+
run: |
192+
$body = Get-Content Release.md -Raw
193+
$body += "`n## Published Packages`n"
194+
$body += "`n| RID | Mode | Archive | Contents |`n| --- | --- | --- | --- |`n"
195+
196+
$metadataFiles = Get-ChildItem -Recurse artifacts -Filter *.json | Sort-Object FullName
197+
foreach ($metadataFile in $metadataFiles) {
198+
$metadata = Get-Content $metadataFile.FullName -Raw | ConvertFrom-Json
199+
$body += "| $($metadata.rid) | $($metadata.mode) | $($metadata.archiveName) | $($metadata.contents -join ', ') |`n"
200+
}
201+
202+
$body += "`n## Build Settings`n"
203+
$body += "`n- Release tag: ${{ inputs.tag_name }}`n"
204+
$body += "- Pre-release: ${{ inputs.prerelease }}`n"
205+
$body += "- Include PDB: ${{ inputs.include_pdb }}`n"
206+
$body += "`n## Assets`n"
207+
foreach ($metadataFile in $metadataFiles) {
208+
$metadata = Get-Content $metadataFile.FullName -Raw | ConvertFrom-Json
209+
$body += "- $($metadata.archiveName)`n"
210+
}
211+
Set-Content -Path release-body.md -Value $body -Encoding utf8
212+
213+
- name: Create GitHub Release
214+
uses: softprops/action-gh-release@v2
215+
with:
216+
tag_name: ${{ inputs.tag_name }}
217+
prerelease: ${{ inputs.prerelease }}
218+
body_path: release-body.md
219+
files: |
220+
artifacts/**/*.zip
221+
artifacts/**/*.tar.gz

Release.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# MCServerLauncher Future Release
2+
3+
This release packages the Windows, Linux, and macOS outputs produced by the GitHub release workflow.
4+
5+
## Package Rules
6+
7+
- Windows packages use `.zip` archives.
8+
- Linux and macOS packages use `.tar.gz` archives.
9+
- Each runtime is published twice: self-contained and framework-dependent.
10+
- Windows packages contain both the WPF client and the daemon.
11+
- Linux and macOS packages contain the daemon only.
12+
13+
## Notes
14+
15+
- The GitHub Release body appends the exact package matrix and uploaded asset names for each run.

0 commit comments

Comments
 (0)