Skip to content

Commit 8729717

Browse files
liuslius
authored andcommitted
ci: migrate Windows Tauri build to GitHub-hosted runner
1 parent de18a67 commit 8729717

1 file changed

Lines changed: 56 additions & 6 deletions

File tree

.github/workflows/tauri-build-win.yml

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ on:
1414
jobs:
1515
build:
1616
# Windows 专用构建 Job:
17-
# - 仅在带有 Windows 标签的 self-hosted Runner 上运行
17+
# - 固定运行在 GitHub-hosted Windows Server 2025 Runner
1818
# - 不适用于 macOS / Linux 等其他平台
1919
# 如需支持多平台,请为不同平台创建独立的 workflow 或 job
20-
runs-on: [self-hosted, Windows]
20+
runs-on: windows-2025
2121
permissions:
2222
contents: write
2323

@@ -54,6 +54,56 @@ jobs:
5454
fetch-depth: 0
5555
fetch-tags: true
5656

57+
- name: Setup pnpm
58+
uses: pnpm/action-setup@v4
59+
with:
60+
version: latest
61+
62+
- name: Setup Node.js
63+
uses: actions/setup-node@v4
64+
with:
65+
node-version: 20
66+
cache: pnpm
67+
68+
- name: Setup Rust toolchain
69+
uses: dtolnay/rust-toolchain@stable
70+
71+
- name: Ensure AWS CLI
72+
shell: powershell
73+
run: |
74+
$ErrorActionPreference = "Stop"
75+
76+
if (Get-Command aws -ErrorAction SilentlyContinue) {
77+
aws --version
78+
exit 0
79+
}
80+
81+
$msiPath = Join-Path $env:RUNNER_TEMP "AWSCLIV2.msi"
82+
Invoke-WebRequest "https://awscli.amazonaws.com/AWSCLIV2.msi" -OutFile $msiPath
83+
Start-Process msiexec.exe -Wait -ArgumentList "/i `"$msiPath`" /qn"
84+
85+
@(
86+
"C:\Program Files\Amazon\AWSCLIV2",
87+
"C:\Program Files\Amazon\AWSCLIV2\bin"
88+
) | ForEach-Object {
89+
if (Test-Path $_) {
90+
Add-Content -Path $env:GITHUB_PATH -Value $_
91+
}
92+
}
93+
94+
$awsExe = Get-Command aws -ErrorAction SilentlyContinue
95+
if (-not $awsExe) {
96+
$awsInstalled = Get-ChildItem "C:\Program Files\Amazon" -Filter aws.exe -Recurse -ErrorAction SilentlyContinue |
97+
Select-Object -First 1
98+
if (-not $awsInstalled) {
99+
Write-Error "AWS CLI installation completed, but aws.exe was not found."
100+
}
101+
& $awsInstalled.FullName --version
102+
exit 0
103+
}
104+
105+
aws --version
106+
57107
- name: Install dependencies
58108
run: pnpm install --frozen-lockfile
59109

@@ -112,8 +162,8 @@ jobs:
112162
- name: Build Tauri app
113163
uses: tauri-apps/tauri-action@v0
114164
env:
115-
# 使用统一的 GT_TOKEN 作为凭证来源
116-
GITHUB_TOKEN: ${{ secrets.GT_TOKEN }}
165+
# 优先使用 GT_TOKEN;未配置时回退到 GitHub 自动注入的 token
166+
GITHUB_TOKEN: ${{ secrets.GT_TOKEN || github.token }}
117167
# Optional: enable updater signing / release signing if you configure them later
118168
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
119169
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
@@ -128,7 +178,7 @@ jobs:
128178
- name: Publish GitHub release assets
129179
if: github.event_name == 'push'
130180
env:
131-
GH_TOKEN: ${{ secrets.GT_TOKEN }}
181+
GH_TOKEN: ${{ secrets.GT_TOKEN || github.token }}
132182
GH_REPO: ${{ github.repository }}
133183
run: node deploy/publish-github-release.mjs
134184

@@ -190,7 +240,7 @@ jobs:
190240
aws s3 cp "latest.json" $dest --endpoint-url $endpoint --region auto
191241
192242
- name: Upload latest.json artifact (manual runs)
193-
if: github.event_name == 'workflow_dispatch'
243+
if: github.event_name == 'workflow_dispatch' && hashFiles('latest.json') != ''
194244
uses: actions/upload-artifact@v4
195245
with:
196246
name: latest-json

0 commit comments

Comments
 (0)