Skip to content

Commit 7f3815a

Browse files
committed
fix: gh action
1 parent 2f468be commit 7f3815a

1 file changed

Lines changed: 130 additions & 33 deletions

File tree

.github/workflows/publish.yml

Lines changed: 130 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,68 @@ on:
1212
description: "Version number (e.g., 2.0.0)"
1313
required: true
1414
type: string
15-
platform:
16-
description: "Platform to ship"
15+
build_windows:
16+
description: "Build Windows installer"
1717
required: true
18-
type: choice
19-
options:
20-
- windows
21-
- linux
22-
- macos
18+
type: boolean
19+
default: true
20+
build_linux:
21+
description: "Build Linux installer"
22+
required: true
23+
type: boolean
24+
default: false
25+
build_macos:
26+
description: "Build macOS installer"
27+
required: true
28+
type: boolean
29+
default: false
2330

2431
jobs:
32+
prepare-platforms:
33+
name: Resolve selected platforms
34+
runs-on: ubuntu-latest
35+
outputs:
36+
platforms_json: ${{ steps.set-platforms.outputs.platforms_json }}
37+
steps:
38+
- name: Build platform matrix
39+
id: set-platforms
40+
shell: bash
41+
run: |
42+
platforms=()
43+
44+
if [[ "${{ inputs.build_windows }}" == "true" ]]; then
45+
platforms+=('"windows"')
46+
fi
47+
48+
if [[ "${{ inputs.build_linux }}" == "true" ]]; then
49+
platforms+=('"linux"')
50+
fi
51+
52+
if [[ "${{ inputs.build_macos }}" == "true" ]]; then
53+
platforms+=('"macos"')
54+
fi
55+
56+
if [[ ${#platforms[@]} -eq 0 ]]; then
57+
echo "At least one platform must be selected."
58+
exit 1
59+
fi
60+
61+
platforms_json="[$(IFS=,; echo "${platforms[*]}")]"
62+
echo "platforms_json=$platforms_json" >> "$GITHUB_OUTPUT"
63+
2564
build-installers:
26-
name: Build installer (${{ inputs.platform }})
27-
runs-on: ${{ inputs.platform == 'windows' && 'windows-latest' || inputs.platform == 'linux' && 'ubuntu-24.04' || 'macos-15' }}
65+
name: Build installer (${{ matrix.platform }})
66+
needs: prepare-platforms
67+
strategy:
68+
fail-fast: false
69+
matrix:
70+
platform: ${{ fromJSON(needs.prepare-platforms.outputs.platforms_json) }}
71+
runs-on: ${{ matrix.platform == 'windows' && 'windows-latest' || matrix.platform == 'linux' && 'ubuntu-24.04' || 'macos-15' }}
2872
steps:
29-
- uses: actions/checkout@v4
73+
- uses: actions/checkout@v6.0.2
3074

3175
- name: Install Linux dependencies
32-
if: inputs.platform == 'linux'
76+
if: matrix.platform == 'linux'
3377
run: |
3478
sudo apt-get update
3579
sudo apt-get install -y \
@@ -39,17 +83,17 @@ jobs:
3983
patchelf
4084
4185
- name: Setup Node.js
42-
uses: actions/setup-node@v4
86+
uses: actions/setup-node@v6.2.0
4387
with:
4488
node-version: lts/*
4589
cache: npm
4690

4791
- name: Install Rust stable
48-
if: inputs.platform != 'macos'
92+
if: matrix.platform != 'macos'
4993
uses: dtolnay/rust-toolchain@stable
5094

5195
- name: Install Rust stable (macOS Apple Silicon target)
52-
if: inputs.platform == 'macos'
96+
if: matrix.platform == 'macos'
5397
uses: dtolnay/rust-toolchain@stable
5498
with:
5599
targets: aarch64-apple-darwin
@@ -63,28 +107,69 @@ jobs:
63107
run: npm ci
64108

65109
- name: Build Tauri installer (Windows NSIS only)
66-
if: inputs.platform == 'windows'
110+
if: matrix.platform == 'windows'
67111
uses: tauri-apps/tauri-action@v0.6.1
68112
env:
69113
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70114
with:
71-
uploadWorkflowArtifacts: true
72115
args: --bundles nsis
73116

74117
- name: Build Tauri installer
75-
if: inputs.platform != 'windows'
118+
if: matrix.platform != 'windows'
76119
uses: tauri-apps/tauri-action@v0.6.1
77120
env:
78121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122+
123+
- name: Stage installer artifacts
124+
id: stage-installers
125+
shell: pwsh
126+
run: |
127+
$bundleRoot = Join-Path $env:GITHUB_WORKSPACE "src-tauri/target/release/bundle"
128+
$stagingRoot = Join-Path $env:GITHUB_WORKSPACE "release-assets"
129+
$platform = "${{ matrix.platform }}"
130+
131+
New-Item -ItemType Directory -Force -Path $stagingRoot | Out-Null
132+
133+
$patterns = switch ($platform) {
134+
"windows" { @("*.exe") }
135+
"linux" { @("*.deb", "*.rpm", "*.AppImage") }
136+
"macos" { @("*.dmg", "*.pkg", "*.app.tar.gz") }
137+
default { @() }
138+
}
139+
140+
if ($patterns.Count -eq 0) {
141+
throw "Unsupported platform selection: $platform"
142+
}
143+
144+
$files = foreach ($pattern in $patterns) {
145+
Get-ChildItem -Path $bundleRoot -Recurse -File -Filter $pattern -ErrorAction SilentlyContinue
146+
}
147+
148+
$files = $files | Sort-Object -Property FullName -Unique
149+
150+
if (-not $files -or $files.Count -eq 0) {
151+
throw "No installer artifacts found under $bundleRoot for platform $platform."
152+
}
153+
154+
foreach ($file in $files) {
155+
Copy-Item -Path $file.FullName -Destination $stagingRoot -Force
156+
}
157+
158+
- name: Upload installer artifacts
159+
uses: actions/upload-artifact@v6.0.0
79160
with:
80-
uploadWorkflowArtifacts: true
161+
name: installer-${{ matrix.platform }}
162+
path: ${{ github.workspace }}/release-assets
163+
if-no-files-found: error
81164

82165
create-release:
83166
runs-on: windows-latest
84-
needs: build-installers
167+
needs:
168+
- prepare-platforms
169+
- build-installers
85170
steps:
86171
- name: Download build artifacts
87-
uses: actions/download-artifact@v7
172+
uses: actions/download-artifact@v7.0.0
88173
with:
89174
path: ${{ github.workspace }}/release-assets
90175

@@ -93,26 +178,38 @@ jobs:
93178
shell: pwsh
94179
run: |
95180
$root = Join-Path $env:GITHUB_WORKSPACE "release-assets"
96-
$platform = "${{ inputs.platform }}"
97-
$patterns = switch ($platform) {
98-
"windows" { @("*.exe") }
99-
"linux" { @("*.deb", "*.rpm", "*.AppImage") }
100-
"macos" { @("*.dmg", "*.pkg", "*.app.tar.gz") }
101-
default { @() }
102-
}
181+
$platforms = '${{ needs.prepare-platforms.outputs.platforms_json }}' | ConvertFrom-Json
182+
$files = @()
103183
104-
if ($patterns.Count -eq 0) {
105-
throw "Unsupported platform selection: $platform"
106-
}
184+
foreach ($platform in $platforms) {
185+
$patterns = switch ($platform) {
186+
"windows" { @("*.exe") }
187+
"linux" { @("*.deb", "*.rpm", "*.AppImage") }
188+
"macos" { @("*.dmg", "*.pkg", "*.app.tar.gz") }
189+
default { @() }
190+
}
107191
108-
$files = foreach ($pattern in $patterns) {
109-
Get-ChildItem -Path $root -Recurse -File -Filter $pattern -ErrorAction SilentlyContinue
192+
if ($patterns.Count -eq 0) {
193+
throw "Unsupported platform selection: $platform"
194+
}
195+
196+
$platformFiles = foreach ($pattern in $patterns) {
197+
Get-ChildItem -Path $root -Recurse -File -Filter $pattern -ErrorAction SilentlyContinue
198+
}
199+
200+
$platformFiles = $platformFiles | Sort-Object -Property FullName -Unique
201+
202+
if (-not $platformFiles -or $platformFiles.Count -eq 0) {
203+
throw "No installer artifacts found under $root for platform $platform."
204+
}
205+
206+
$files += $platformFiles
110207
}
111208
112209
$files = $files | Sort-Object -Property FullName -Unique
113210
114211
if (-not $files -or $files.Count -eq 0) {
115-
throw "No installer artifacts found under $root for platform $platform."
212+
throw "No installer artifacts found under $root."
116213
}
117214
118215
$artifactList = ($files | ForEach-Object { $_.FullName }) -join ","

0 commit comments

Comments
 (0)