Repository navigation
197 lines (176 loc) · 7.21 KB
/
Copy pathdev-release.yml
File metadata and controls
197 lines (176 loc) · 7.21 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
195
196
197
name: Dev Release
on:
workflow_dispatch:
inputs:
dev_increment:
description: 'Version increment for this developer release'
required: true
default: patch
type: choice
options:
- patch
- minor
- major
concurrency:
group: dev-release
cancel-in-progress: false
jobs:
publish-dev:
runs-on: windows-latest
permissions:
contents: write
env:
DEV_RELEASE_TAG: dev
DEV_UPDATE_ENDPOINT: https://github.com/JosephLteif/simcraft/releases/download/dev/latest.json
steps:
- name: Checkout dev
uses: actions/checkout@v7
with:
ref: dev
fetch-depth: 0
- name: Move dev release tag
id: dev_ref
shell: pwsh
run: |
$devSha = (git rev-parse HEAD).Trim()
git tag --force $env:DEV_RELEASE_TAG $devSha
git push origin "refs/tags/$env:DEV_RELEASE_TAG" --force
"dev_sha=$devSha" >> $env:GITHUB_OUTPUT
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 22.22.2
cache: npm
cache-dependency-path: |
package-lock.json
frontend/package-lock.json
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.95
- name: Install dependencies
shell: pwsh
run: npm ci; npm ci --prefix frontend
- name: Prepare developer version
id: prepare
shell: pwsh
env:
RUN_NUMBER: ${{ github.run_number }}
RUN_ATTEMPT: ${{ github.run_attempt }}
DEV_INCREMENT: ${{ inputs.dev_increment }}
run: |
$stableVersion = (Get-Content VERSION -Raw).Trim()
if ($stableVersion -notmatch '^\d+\.\d+\.\d+$') {
throw "VERSION must contain a stable semantic version before creating a dev build: $stableVersion"
}
$versionParts = $stableVersion.Split('.') | ForEach-Object { [int]$_ }
switch ($env:DEV_INCREMENT) {
'major' {
$versionParts[0]++
$versionParts[1] = 0
$versionParts[2] = 0
}
'minor' {
$versionParts[1]++
$versionParts[2] = 0
}
'patch' { $versionParts[2]++ }
default { throw "DEV_INCREMENT must be patch, minor, or major: $env:DEV_INCREMENT" }
}
$targetVersion = $versionParts -join '.'
git ls-remote --exit-code origin "refs/tags/v$targetVersion" *> $null
$tagCheckExitCode = $LASTEXITCODE
if ($tagCheckExitCode -eq 0) {
throw "Stable release tag v$targetVersion already exists; choose another increment type."
}
if ($tagCheckExitCode -ne 2) {
throw "Unable to verify whether stable release tag v$targetVersion exists."
}
$devVersion = "$targetVersion-dev.$env:RUN_NUMBER.$env:RUN_ATTEMPT"
Set-Content -Path VERSION -Value $devVersion -NoNewline
npm run sync:version
npm install --package-lock-only --ignore-scripts
npm install --prefix frontend --package-lock-only --ignore-scripts
$configPath = 'desktop/src-tauri/tauri.conf.json'
$config = Get-Content $configPath -Raw | ConvertFrom-Json
$config.plugins.updater.endpoints = @($env:DEV_UPDATE_ENDPOINT)
$config | ConvertTo-Json -Depth 100 | Set-Content $configPath
npm run verify:release -- $devVersion
"dev_version=$devVersion" >> $env:GITHUB_OUTPUT
- name: Ensure bundled resource paths exist
shell: pwsh
run: |
New-Item -ItemType Directory -Force backend/resources/data | Out-Null
if (-not (Test-Path backend/resources/zones-encounters-index.json)) {
throw 'backend/resources/zones-encounters-index.json is required for dev bundles'
}
foreach ($file in @('wow-expansions.json', 'wow-instances.json', 'wow-encounters.json', 'wow-seasons.json')) {
if (-not (Test-Path "backend/resources/wow/$file")) {
throw "backend/resources/wow/$file is required for dev bundles"
}
}
Copy-Item backend/resources/zones-encounters-index.json backend/resources/data/zones-encounters-index.json -Force
New-Item -ItemType File -Force backend/resources/data/.keep | Out-Null
- name: Build and publish developer desktop app
uses: tauri-apps/tauri-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
DESKTOP_BUILD: true
NEXT_PUBLIC_DESKTOP_BUILD: true
with:
projectPath: desktop
tagName: dev
releaseName: WhyLowDps Dev
releaseBody: 'Automated developer build for testing before a stable release.'
releaseDraft: false
prerelease: true
args: --config src-tauri/tauri.conf.json --bundles nsis
- name: Upload developer data asset
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload dev backend/resources/zones-encounters-index.json --clobber
- name: Refresh moving developer release metadata
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEV_VERSION: ${{ steps.prepare.outputs.dev_version }}
DEV_INCREMENT: ${{ inputs.dev_increment }}
run: |
$notesPath = Join-Path $env:RUNNER_TEMP 'dev-release-notes.md'
@"
Automated developer build for testing before a stable release.
Version: $env:DEV_VERSION
Increment: $env:DEV_INCREMENT
Source: ${{ steps.dev_ref.outputs.dev_sha }}
Source ref: dev-build/$env:DEV_VERSION
"@ | Set-Content $notesPath
gh release edit dev --title 'WhyLowDps Dev' --notes-file $notesPath --prerelease --draft=false
- name: Verify developer updater manifest
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$assets = @(gh release view dev --json assets --jq '.assets[].name' | ForEach-Object { $_.Trim() })
if (-not ($assets -contains 'latest.json')) {
throw 'The dev release does not contain latest.json; the updater cannot update installed dev builds.'
}
- name: Preserve immutable developer source tag
shell: pwsh
env:
DEV_SHA: ${{ steps.dev_ref.outputs.dev_sha }}
DEV_VERSION: ${{ steps.prepare.outputs.dev_version }}
run: |
$devTag = "dev-build/$env:DEV_VERSION"
git ls-remote --exit-code origin "refs/tags/$devTag" *> $null
$tagCheckExitCode = $LASTEXITCODE
if ($tagCheckExitCode -eq 0) {
throw "Developer source tag $devTag already exists; refusing to overwrite it."
}
if ($tagCheckExitCode -ne 2) {
throw "Unable to verify whether developer source tag $devTag exists."
}
git tag $devTag $env:DEV_SHA
git push origin "refs/tags/$devTag"