-
Notifications
You must be signed in to change notification settings - Fork 1
250 lines (219 loc) · 7.6 KB
/
Copy pathrelease.yml
File metadata and controls
250 lines (219 loc) · 7.6 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Release tag, for example v0.6.3 or v0.6.3-preview"
required: true
default: "v0.6.3"
create_release:
description: "Create or update the GitHub release"
required: true
default: true
type: boolean
draft_release:
description: "Create a draft release when manually triggered"
required: true
default: true
type: boolean
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build-macos-universal:
name: Build macOS universal DMG
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set release tag
id: release_tag
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
tag="${{ inputs.version }}"
else
tag="${GITHUB_REF_NAME}"
fi
echo "RELEASE_TAG=${tag}" >> "$GITHUB_ENV"
echo "value=${tag}" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.x"
cache: true
- name: Verify version consistency
run: go run scripts/check-version.go "$RELEASE_TAG"
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: npm ci --prefix frontend
- name: Install Wails CLI
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.12.0
- name: Build DMG
run: scripts/build-macos.sh "$RELEASE_TAG"
- name: Verify artifacts
shell: bash
run: |
lipo -archs build/bin/CatScope.app/Contents/MacOS/CatScope
cd dist
shasum -a 256 -c "CatScope-${RELEASE_TAG}-macos-universal.dmg.sha256"
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: "CatScope-${{ steps.release_tag.outputs.value }}-macos-universal"
path: |
dist/CatScope-${{ steps.release_tag.outputs.value }}-macos-universal.dmg
dist/CatScope-${{ steps.release_tag.outputs.value }}-macos-universal.dmg.sha256
if-no-files-found: error
build-windows-amd64:
name: Build Windows amd64 EXE
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set release tag
id: release_tag
shell: pwsh
run: |
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$tag = "${{ inputs.version }}"
} else {
$tag = "${env:GITHUB_REF_NAME}"
}
"RELEASE_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"value=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.x"
cache: true
- name: Verify version consistency
shell: pwsh
run: go run scripts/check-version.go "$env:RELEASE_TAG"
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: npm ci --prefix frontend
- name: Install Wails CLI
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.12.0
- name: Build EXE
shell: pwsh
run: scripts\build-windows.ps1
- name: Package Windows artifact
shell: pwsh
run: |
$artifactName = "CatScope-$env:RELEASE_TAG-windows-amd64.exe"
New-Item -ItemType Directory -Force -Path dist | Out-Null
Copy-Item -Path build\bin\CatScope.exe -Destination "dist\$artifactName"
$hash = (Get-FileHash "dist\$artifactName" -Algorithm SHA256).Hash.ToLowerInvariant()
"$hash $artifactName" | Set-Content -Path "dist\$artifactName.sha256" -NoNewline -Encoding ascii
- name: Verify artifact
shell: pwsh
run: |
$artifactName = "CatScope-$env:RELEASE_TAG-windows-amd64.exe"
if (-not (Test-Path "dist\$artifactName")) {
throw "Missing dist\$artifactName"
}
Get-FileHash "dist\$artifactName" -Algorithm SHA256
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: "CatScope-${{ steps.release_tag.outputs.value }}-windows-amd64"
path: |
dist/CatScope-${{ steps.release_tag.outputs.value }}-windows-amd64.exe
dist/CatScope-${{ steps.release_tag.outputs.value }}-windows-amd64.exe.sha256
if-no-files-found: error
create-github-release:
name: Create GitHub release
runs-on: ubuntu-latest
needs:
- build-macos-universal
- build-windows-amd64
if: github.event_name == 'push' || inputs.create_release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set release tag
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
tag="${{ inputs.version }}"
draft="${{ inputs.draft_release }}"
else
tag="${GITHUB_REF_NAME}"
if [[ "$tag" == *"-preview"* ]]; then
draft="true"
else
draft="false"
fi
fi
if [[ "$tag" == *"-preview"* ]]; then
preview="true"
else
preview="false"
fi
echo "RELEASE_TAG=${tag}" >> "$GITHUB_ENV"
echo "IS_PREVIEW=${preview}" >> "$GITHUB_ENV"
echo "IS_DRAFT=${draft}" >> "$GITHUB_ENV"
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
pattern: "CatScope-*"
path: dist
merge-multiple: true
- name: Prepare release notes
shell: bash
run: |
notes_file="docs/releases/${RELEASE_TAG}.md"
if [[ -f "$notes_file" ]]; then
echo "RELEASE_NOTES=$notes_file" >> "$GITHUB_ENV"
else
mkdir -p .github/generated
generated=".github/generated/${RELEASE_TAG}.md"
{
echo "# CatScope ${RELEASE_TAG}"
echo
if [[ "$IS_PREVIEW" == "true" ]]; then
echo "Preview release assets generated by GitHub Actions."
else
echo "Release assets generated by GitHub Actions."
fi
} > "$generated"
echo "RELEASE_NOTES=$generated" >> "$GITHUB_ENV"
fi
- name: Create or update GitHub release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" \
dist/CatScope-"${RELEASE_TAG}"-* \
--clobber
else
release_flags=()
if [[ "$IS_DRAFT" == "true" ]]; then
release_flags+=(--draft)
fi
if [[ "$IS_PREVIEW" == "true" ]]; then
release_flags+=(--prerelease --latest=false)
else
release_flags+=(--latest)
fi
gh release create "$RELEASE_TAG" \
dist/CatScope-"${RELEASE_TAG}"-* \
"${release_flags[@]}" \
--title "CatScope ${RELEASE_TAG}" \
--notes-file "$RELEASE_NOTES"
fi