@@ -3,101 +3,172 @@ name: Release Workflow
33on :
44 push :
55 tags :
6- - ' *.*.*'
6+ - " [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
7+
8+ permissions :
9+ contents : write
10+
11+ env :
12+ DEMO_URL : https://nnnsmm.github.io/Launcherg-Mod/
13+ RELEASE_URL : https://github.com/nnnSMM/Launcherg-Mod/releases
714
815jobs :
916 release :
1017 runs-on : windows-latest
1118
1219 steps :
1320 - name : Checkout code
14- uses : actions/checkout@v2
21+ uses : actions/checkout@v4
1522
16- - name : Extract tag name
23+ - name : Extract release versions
1724 id : variables
18- run : echo "version=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
19- shell : bash
25+ shell : pwsh
26+ run : |
27+ $tagName = "${env:GITHUB_REF_NAME}" -replace '^v', ''
28+ if ($tagName -match '^\d{8}$') {
29+ $year = [int]$tagName.Substring(2, 2)
30+ $month = [int]$tagName.Substring(4, 2)
31+ $day = [int]$tagName.Substring(6, 2)
32+ $appVersion = "${year}.${month}.${day}"
33+ $displayVersion = $tagName
34+ } else {
35+ throw "Unsupported release tag '${tagName}'. Use YYYYMMDD, for example 20260524."
36+ }
37+ "tag_name=${tagName}" >> $env:GITHUB_OUTPUT
38+ "app_version=${appVersion}" >> $env:GITHUB_OUTPUT
39+ "display_version=${displayVersion}" >> $env:GITHUB_OUTPUT
40+
41+ - name : Setup Node
42+ uses : actions/setup-node@v4
43+ with :
44+ node-version : 24
45+ cache : npm
46+
47+ - name : Install dependencies
48+ run : npm ci
49+
50+ - name : Check frontend
51+ run : npm run check
52+
53+ - name : Build demo before release
54+ run : npm run build-demo
55+
56+ - name : Verify demo build output
57+ shell : pwsh
58+ run : |
59+ if (!(Test-Path "docs/demo/index.html")) {
60+ throw "docs/demo/index.html was not generated."
61+ }
62+
63+ - name : Check published demo URL
64+ shell : pwsh
65+ run : |
66+ try {
67+ $response = Invoke-WebRequest -Uri "${{ env.DEMO_URL }}" -Method Head -UseBasicParsing -TimeoutSec 20
68+ if ($response.StatusCode -lt 200 -or $response.StatusCode -ge 400) {
69+ throw "Unexpected status code: $($response.StatusCode)"
70+ }
71+ } catch {
72+ Write-Warning "Published demo URL could not be verified. The local demo build succeeded, so release can continue. $($_.Exception.Message)"
73+ }
2074
21- - name : Update package.version in tauri.conf.json
75+ - name : Update app version in tauri.conf.json
76+ shell : pwsh
2277 run : |
2378 $json = Get-Content -Path "src-tauri\tauri.conf.json" -Raw | ConvertFrom-Json
24- $json.package. version = "${{ steps.variables.outputs.version }}"
79+ $json.version = "${{ steps.variables.outputs.app_version }}"
2580 $json | ConvertTo-Json -Depth 100 | Set-Content -Path "src-tauri\tauri.conf.json"
2681
27- - uses : actions/cache@v3
82+ - uses : actions/cache@v4
2883 with :
2984 path : |
3085 ~/.cargo/bin/
3186 ~/.cargo/registry/index/
3287 ~/.cargo/registry/cache/
3388 ~/.cargo/git/db/
34- target/
89+ src-tauri/ target/
3590 key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3691
37- - uses : actions/setup-node@v3
38-
39- - name : Install dependencies and build
92+ - name : Build Tauri app
4093 env :
4194 TAURI_KEY_PASSWORD : ${{ secrets.TAURI_KEY_PASSWORD }}
4295 TAURI_PRIVATE_KEY : ${{ secrets.TAURI_PRIVATE_KEY }}
43- run : |
44- npm i
45- npm run tauri build
46-
47- - uses : ncipollo/release-action@v1
48- with :
49- artifacts : .\src-tauri\target\release\bundle\msi\Launcherg_${{ steps.variables.outputs.version }}_x64_ja-JP.msi.zip
50- token : ${{ secrets.GITHUB_TOKEN }}
51- prerelease : true
96+ TAURI_SIGNING_PRIVATE_KEY : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY || secrets.TAURI_PRIVATE_KEY }}
97+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD || secrets.TAURI_KEY_PASSWORD }}
98+ run : npm run tauri build
5299
53- - name : Update .tauri-updater.json
100+ - name : Generate updater and UI metadata
101+ shell : pwsh
54102 run : |
55- $env:TEMP_SIGNATURE = Get-Content -Path ".\src-tauri\target\release\bundle\msi\Launcherg_${{ steps.variables.outputs.version }}_x64_ja-JP.msi.zip.sig"
56- $data = @{
57- version = "${{ steps.variables.outputs.version }}"
58- notes = "See the assets to download this version and install."
59- pub_date = (Get-Date -Format s) + "Z"
60- signature = $env:TEMP_SIGNATURE
61- url = "https://github.com/ryoha000/launcherg/releases/download/${{ steps.variables.outputs.version }}/Launcherg_${{ steps.variables.outputs.version }}_x64_ja-JP.msi.zip"
103+ $tagName = "${{ steps.variables.outputs.tag_name }}"
104+ $appVersion = "${{ steps.variables.outputs.app_version }}"
105+ $displayVersion = "${{ steps.variables.outputs.display_version }}"
106+ $builtArtifactName = "Launcherg_${appVersion}_x64_ja-JP.msi.zip"
107+ $releaseArtifactName = "Launcherg_${displayVersion}_x64_ja-JP.msi.zip"
108+ $builtArtifactPath = ".\src-tauri\target\release\bundle\msi\${builtArtifactName}"
109+ $builtSignaturePath = "${builtArtifactPath}.sig"
110+ $releaseArtifactPath = ".\src-tauri\target\release\bundle\msi\${releaseArtifactName}"
111+ $releaseSignaturePath = "${releaseArtifactPath}.sig"
112+ if (!(Test-Path $builtArtifactPath)) {
113+ throw "Updater artifact was not found: ${builtArtifactPath}"
114+ }
115+ if (!(Test-Path $builtSignaturePath)) {
116+ throw "Updater signature was not found: ${builtSignaturePath}"
117+ }
118+ if ($builtArtifactPath -ne $releaseArtifactPath) {
119+ Copy-Item -Path $builtArtifactPath -Destination $releaseArtifactPath -Force
120+ Copy-Item -Path $builtSignaturePath -Destination $releaseSignaturePath -Force
62121 }
63- $data | ConvertTo-Json | Set-Content -Path ".tauri-updater.json"
64- - name : format files
65- run : npx -y prettier .\src-tauri\tauri.conf.json .\.tauri-updater.json --write
66122
67- - name : Archive production artifacts
68- uses : actions/upload-artifact@v3
69- with :
70- name : changed-files
71- path : |
72- src-tauri/tauri.conf.json
73- .tauri-updater.json
123+ $pubDate = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
124+ $downloadUrl = "${{ env.RELEASE_URL }}/download/${tagName}/${releaseArtifactName}"
125+ $signature = (Get-Content -Path $releaseSignaturePath -Raw).Trim()
126+ $notes = "See the release notes and demo before updating."
74127
75- push-changed-files :
76- runs-on : ubuntu-latest
77- needs : release
78- steps :
79- - name : Checkout code
80- uses : actions/checkout@v2
81- with :
82- ref : main
83-
84- - name : Download artifacts
85- uses : actions/download-artifact@v3
86- with :
87- name : changed-files
88- path : changed-files
89-
90- - name : Move files to correct locations
91- run : |
92- mv changed-files/src-tauri/tauri.conf.json src-tauri/tauri.conf.json
93- mv changed-files/.tauri-updater.json .tauri-updater.json
128+ $updaterData = @{
129+ version = $appVersion
130+ notes = $notes
131+ pub_date = $pubDate
132+ signature = $signature
133+ url = $downloadUrl
134+ }
135+ $updaterData | ConvertTo-Json -Depth 10 | Set-Content -Path ".tauri-updater.json"
94136
95- - name : Push updated files to main
137+ $uiInfo = @{
138+ version = $appVersion
139+ displayVersion = $displayVersion
140+ pubDate = $pubDate
141+ demoUrl = "${{ env.DEMO_URL }}"
142+ releaseUrl = "${{ env.RELEASE_URL }}/tag/${tagName}"
143+ highlights = @()
144+ }
145+ $uiInfo | ConvertTo-Json -Depth 10 | Set-Content -Path "update-info.json"
146+
147+ - name : Verify updater manifest
148+ shell : pwsh
96149 run : |
97- git config --local user.email "action@github.com"
98- git config --local user.name "GitHub Action"
99- git add src-tauri/tauri.conf.json
100- git add .tauri-updater.json
101- git commit -m "Update for release ${{ steps.variables.outputs.version }}"
102- git push origin main
103- shell : bash
150+ $tagName = "${{ steps.variables.outputs.tag_name }}"
151+ $appVersion = "${{ steps.variables.outputs.app_version }}"
152+ $displayVersion = "${{ steps.variables.outputs.display_version }}"
153+ $expectedUrl = "${{ env.RELEASE_URL }}/download/${tagName}/Launcherg_${displayVersion}_x64_ja-JP.msi.zip"
154+ $data = Get-Content -Path ".tauri-updater.json" -Raw | ConvertFrom-Json
155+ if ($data.version -ne $appVersion) {
156+ throw "Unexpected updater version: $($data.version)"
157+ }
158+ if ($data.url -ne $expectedUrl) {
159+ throw "Unexpected updater URL: $($data.url)"
160+ }
161+ if ([string]::IsNullOrWhiteSpace($data.signature)) {
162+ throw "Updater signature is empty."
163+ }
164+ Write-Host "Updater manifest verified: version=$($data.version), url=$($data.url)"
165+
166+ - name : Format generated metadata
167+ run : npx -y prettier .\src-tauri\tauri.conf.json .\.tauri-updater.json .\update-info.json --write
168+
169+ - name : Create GitHub release
170+ uses : ncipollo/release-action@v1
171+ with :
172+ artifacts : " .\\ src-tauri\\ target\\ release\\ bundle\\ msi\\ Launcherg_${{ steps.variables.outputs.display_version }}_x64_ja-JP.msi.zip,.\\ src-tauri\\ target\\ release\\ bundle\\ msi\\ Launcherg_${{ steps.variables.outputs.display_version }}_x64_ja-JP.msi.zip.sig,.\\ .tauri-updater.json,.\\ update-info.json"
173+ token : ${{ secrets.GITHUB_TOKEN }}
174+ prerelease : true
0 commit comments