-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (172 loc) · 8.02 KB
/
Copy pathrelease.yaml
File metadata and controls
194 lines (172 loc) · 8.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Release Workflow
on:
push:
tags:
- "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
permissions:
contents: write
env:
DEMO_URL: https://nnnsmm.github.io/Launcherg-Mod/
RELEASE_URL: https://github.com/nnnSMM/Launcherg-Mod/releases
jobs:
release:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract release versions
id: variables
shell: pwsh
run: |
$tagName = "${env:GITHUB_REF_NAME}" -replace '^v', ''
if ($tagName -match '^\d{8}$') {
$year = [int]$tagName.Substring(2, 2)
$month = [int]$tagName.Substring(4, 2)
$day = [int]$tagName.Substring(6, 2)
$appVersion = "${year}.${month}.${day}"
$displayVersion = $tagName
$releaseTitle = (Get-Content -Path 'release-display-version.txt' -Raw).Trim()
if ($releaseTitle -notmatch '^\d+\.\d+\.\d+$') {
throw "Unsupported release display version '${releaseTitle}'. Use a semver-like value such as 0.4.0."
}
} else {
throw "Unsupported release tag '${tagName}'. Use YYYYMMDD, for example 20260524."
}
"tag_name=${tagName}" >> $env:GITHUB_OUTPUT
"app_version=${appVersion}" >> $env:GITHUB_OUTPUT
"display_version=${displayVersion}" >> $env:GITHUB_OUTPUT
"release_title=${releaseTitle}" >> $env:GITHUB_OUTPUT
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Check frontend
run: npm run check
- name: Build demo before release
run: npm run build-demo
- name: Verify demo build output
shell: pwsh
run: |
if (!(Test-Path "docs/demo/index.html")) {
throw "docs/demo/index.html was not generated."
}
- name: Check published demo URL
shell: pwsh
run: |
try {
$response = Invoke-WebRequest -Uri "${{ env.DEMO_URL }}" -Method Head -UseBasicParsing -TimeoutSec 20
if ($response.StatusCode -lt 200 -or $response.StatusCode -ge 400) {
throw "Unexpected status code: $($response.StatusCode)"
}
} catch {
Write-Warning "Published demo URL could not be verified. The local demo build succeeded, so release can continue. $($_.Exception.Message)"
}
- name: Update app version in tauri.conf.json
shell: pwsh
run: |
$json = Get-Content -Path "src-tauri/tauri.conf.json" -Raw | ConvertFrom-Json
$json.version = "${{ steps.variables.outputs.app_version }}"
$json | ConvertTo-Json -Depth 100 | Set-Content -Path "src-tauri/tauri.conf.json"
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build Tauri app
env:
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY || secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD || secrets.TAURI_KEY_PASSWORD }}
run: npm run tauri build
- name: Generate updater and UI metadata
shell: pwsh
run: |
$tagName = "${{ steps.variables.outputs.tag_name }}"
$appVersion = "${{ steps.variables.outputs.app_version }}"
$displayVersion = "${{ steps.variables.outputs.display_version }}"
$releaseTitle = "${{ steps.variables.outputs.release_title }}"
$builtArtifactName = "Launcherg_${appVersion}_x64_ja-JP.msi.zip"
$releaseArtifactName = "Launcherg_${displayVersion}_x64_ja-JP.msi.zip"
$builtArtifactPath = "src-tauri/target/release/bundle/msi/${builtArtifactName}"
$builtSignaturePath = "${builtArtifactPath}.sig"
$releaseArtifactPath = "src-tauri/target/release/bundle/msi/${releaseArtifactName}"
$releaseSignaturePath = "${releaseArtifactPath}.sig"
if (!(Test-Path $builtArtifactPath)) {
throw "Updater artifact was not found: ${builtArtifactPath}"
}
if (!(Test-Path $builtSignaturePath)) {
throw "Updater signature was not found: ${builtSignaturePath}"
}
if ($builtArtifactPath -ne $releaseArtifactPath) {
Copy-Item -Path $builtArtifactPath -Destination $releaseArtifactPath -Force
Copy-Item -Path $builtSignaturePath -Destination $releaseSignaturePath -Force
}
$pubDate = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
$downloadUrl = "${{ env.RELEASE_URL }}/download/${tagName}/${releaseArtifactName}"
$signature = (Get-Content -Path $releaseSignaturePath -Raw).Trim()
$notes = "See the release notes and demo before updating."
$updaterData = @{
version = $appVersion
notes = $notes
pub_date = $pubDate
signature = $signature
url = $downloadUrl
}
$updaterData | ConvertTo-Json -Depth 10 | Set-Content -Path "default.tauri-updater.json"
$uiInfo = @{
version = $appVersion
displayVersion = $releaseTitle
pubDate = $pubDate
demoUrl = "${{ env.DEMO_URL }}"
releaseUrl = "${{ env.RELEASE_URL }}/tag/${tagName}"
highlights = @()
}
$uiInfo | ConvertTo-Json -Depth 10 | Set-Content -Path "update-info.json"
- name: Verify updater manifest
shell: pwsh
run: |
$tagName = "${{ steps.variables.outputs.tag_name }}"
$appVersion = "${{ steps.variables.outputs.app_version }}"
$displayVersion = "${{ steps.variables.outputs.display_version }}"
$expectedUrl = "${{ env.RELEASE_URL }}/download/${tagName}/Launcherg_${displayVersion}_x64_ja-JP.msi.zip"
$data = Get-Content -Path "default.tauri-updater.json" -Raw | ConvertFrom-Json
if ($data.version -ne $appVersion) {
throw "Unexpected updater version: $($data.version)"
}
if ($data.url -ne $expectedUrl) {
throw "Unexpected updater URL: $($data.url)"
}
if ([string]::IsNullOrWhiteSpace($data.signature)) {
throw "Updater signature is empty."
}
$uiInfo = Get-Content -Path "update-info.json" -Raw | ConvertFrom-Json
if ($uiInfo.version -ne $appVersion) {
throw "Unexpected update UI metadata version: $($uiInfo.version)"
}
if ($uiInfo.displayVersion -ne "${{ steps.variables.outputs.release_title }}") {
throw "Unexpected update UI display version: $($uiInfo.displayVersion)"
}
if ($uiInfo.releaseUrl -ne "${{ env.RELEASE_URL }}/tag/${tagName}") {
throw "Unexpected update UI release URL: $($uiInfo.releaseUrl)"
}
Write-Host "Updater manifest verified: version=$($data.version), url=$($data.url)"
- name: Format generated metadata
run: npx -y prettier src-tauri/tauri.conf.json default.tauri-updater.json update-info.json --write
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
name: ${{ steps.variables.outputs.release_title }}
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,default.tauri-updater.json,update-info.json"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
removeArtifacts: true
replacesArtifacts: true
prerelease: false