-
Notifications
You must be signed in to change notification settings - Fork 6
379 lines (330 loc) · 11.2 KB
/
Copy pathdesktop-release.yml
File metadata and controls
379 lines (330 loc) · 11.2 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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
name: Desktop Release
run-name: Desktop release ${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: "Desktop app version to release, for example 0.0.2 or v0.0.2"
required: true
type: string
release_name:
description: "Release title. Defaults to the tag."
required: false
type: string
qwen_code_version:
description: "Optional @qwen-code/qwen-code version to vendor into the desktop app."
required: false
type: string
dry_run:
description: "Build installers only. Do not create or update a GitHub Release."
required: true
default: true
type: boolean
draft:
description: "Create a draft release."
required: true
default: true
type: boolean
prerelease:
description: "Mark the release as a prerelease."
required: true
default: false
type: boolean
clobber:
description: "Replace same-named assets when uploading to an existing release."
required: true
default: false
type: boolean
permissions:
contents: read
concurrency:
group: desktop-release-${{ inputs.version }}
cancel-in-progress: false
env:
BUN_VERSION: 1.3.9
CRAFT_BRAND: openwork
QWEN_CODE_VERSION: ${{ inputs.qwen_code_version }}
jobs:
release_metadata:
name: Prepare Release Source
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
outputs:
release_branch: ${{ steps.release-branch.outputs.branch }}
release_ref: ${{ steps.release-branch.outputs.ref }}
tag: ${{ steps.release-version.outputs.tag }}
version: ${{ steps.release-version.outputs.version }}
steps:
- name: Check out source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Configure Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Require main for publishing
if: ${{ inputs.dry_run == false }}
env:
SOURCE_REF: ${{ github.ref_name }}
run: |
set -euo pipefail
if [ "$SOURCE_REF" != "main" ]; then
echo "::error::Desktop releases with dry_run=false must be run from main. Current ref: $SOURCE_REF"
exit 1
fi
- name: Bump desktop version
env:
INPUT_VERSION: ${{ inputs.version }}
run: bun run bump-desktop-version "$INPUT_VERSION"
- name: Validate release version
id: release-version
env:
INPUT_VERSION: ${{ inputs.version }}
run: bun run check-release-version --version "$INPUT_VERSION"
- name: Create release branch
id: release-branch
env:
IS_DRY_RUN: ${{ inputs.dry_run }}
RELEASE_TAG: ${{ steps.release-version.outputs.tag }}
run: |
set -euo pipefail
branch="release/desktop-${RELEASE_TAG}"
git switch -c "$branch"
git add package.json apps/electron/package.json packages/shared/package.json
if git diff --staged --quiet; then
echo "No desktop version changes to commit."
else
git commit -m "chore(release): desktop ${RELEASE_TAG}"
fi
echo "branch=$branch" >> "$GITHUB_OUTPUT"
if [ "$IS_DRY_RUN" = "false" ]; then
git push --set-upstream origin "$branch"
echo "ref=$branch" >> "$GITHUB_OUTPUT"
else
echo "Dry run enabled. Skipping release branch push."
echo "ref=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
fi
build:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
needs: release_metadata
env:
RELEASE_TAG: ${{ needs.release_metadata.outputs.tag }}
RELEASE_VERSION: ${{ needs.release_metadata.outputs.version }}
strategy:
fail-fast: false
matrix:
include:
- name: macOS
os: macos-latest
command: bun run dist:mac
- name: Windows
os: windows-latest
command: bun run dist:win
- name: Linux
os: ubuntu-22.04
command: bun run dist:linux
steps:
- name: Check out source
uses: actions/checkout@v4
with:
ref: ${{ needs.release_metadata.outputs.release_ref }}
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install Linux packaging dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libfuse2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Bump desktop version
run: bun run bump-desktop-version "$RELEASE_VERSION"
- name: Confirm release version
run: bun run check-release-version --version "$RELEASE_VERSION"
- name: Build desktop installer
run: ${{ matrix.command }}
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
SENTRY_ELECTRON_INGEST_URL: ${{ secrets.SENTRY_ELECTRON_INGEST_URL }}
- name: Upload installer artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-${{ matrix.name }}
if-no-files-found: error
retention-days: 14
path: |
apps/electron/release/*.AppImage
apps/electron/release/*.blockmap
apps/electron/release/*.dmg
apps/electron/release/*.exe
apps/electron/release/*.yml
apps/electron/release/*.zip
publish:
name: Publish GitHub Release
runs-on: ubuntu-latest
timeout-minutes: 20
needs:
- build
- release_metadata
if: ${{ inputs.dry_run == false }}
permissions:
contents: write
env:
RELEASE_TAG: ${{ needs.release_metadata.outputs.tag }}
RELEASE_VERSION: ${{ needs.release_metadata.outputs.version }}
steps:
- name: Download installer artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- name: Publish release assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_DRAFT: ${{ inputs.draft }}
RELEASE_NAME: ${{ inputs.release_name }}
RELEASE_PRERELEASE: ${{ inputs.prerelease }}
RELEASE_TARGET: ${{ needs.release_metadata.outputs.release_ref }}
UPLOAD_CLOBBER: ${{ inputs.clobber }}
run: |
set -euo pipefail
assets=()
while IFS= read -r -d '' file; do
assets+=("$file")
done < <(find release-assets -type f -print0 | sort -z)
if [ "${#assets[@]}" -eq 0 ]; then
echo "No release assets were downloaded."
exit 1
fi
printf 'Release assets:\n'
printf ' %s\n' "${assets[@]}"
title="${RELEASE_NAME:-$RELEASE_TAG}"
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
upload_args=("$RELEASE_TAG" "${assets[@]}")
if [ "$UPLOAD_CLOBBER" = "true" ]; then
upload_args+=(--clobber)
fi
gh release upload "${upload_args[@]}"
else
create_args=(
"$RELEASE_TAG"
"${assets[@]}"
--generate-notes
--target "$RELEASE_TARGET"
--title "$title"
)
if [ "$RELEASE_DRAFT" = "true" ]; then
create_args+=(--draft)
fi
if [ "$RELEASE_PRERELEASE" = "true" ]; then
create_args+=(--prerelease)
fi
gh release create "${create_args[@]}"
fi
sync-version:
name: Sync Release Version to Main
runs-on: ubuntu-latest
timeout-minutes: 10
needs:
- publish
- release_metadata
if: ${{ inputs.dry_run == false }}
permissions:
contents: write
pull-requests: write
steps:
- name: Create version sync PR
id: version-pr
env:
GH_TOKEN: ${{ secrets.CI_BOT_PAT || github.token }}
RELEASE_BRANCH: ${{ needs.release_metadata.outputs.release_branch }}
RELEASE_TAG: ${{ needs.release_metadata.outputs.tag }}
run: |
set -euo pipefail
pr_url="$(gh pr list \
--repo "$GITHUB_REPOSITORY" \
--head "$RELEASE_BRANCH" \
--base main \
--json url \
--jq '.[0].url')"
if [ -z "$pr_url" ]; then
pr_url="$(gh pr create \
--repo "$GITHUB_REPOSITORY" \
--base main \
--head "$RELEASE_BRANCH" \
--title "chore(release): desktop ${RELEASE_TAG}" \
--body "Automated desktop release PR for ${RELEASE_TAG}. Syncs desktop package versions on main.")"
fi
echo "url=$pr_url" >> "$GITHUB_OUTPUT"
- name: Enable auto-merge
env:
GH_TOKEN: ${{ secrets.CI_BOT_PAT || github.token }}
PR_URL: ${{ steps.version-pr.outputs.url }}
RELEASE_TAG: ${{ needs.release_metadata.outputs.tag }}
run: |
set -euo pipefail
gh pr merge "$PR_URL" \
--squash \
--auto \
--delete-branch \
--subject "chore(release): desktop ${RELEASE_TAG} [skip ci]"
dry-run-summary:
name: Dry Run Summary
runs-on: ubuntu-latest
timeout-minutes: 10
needs:
- build
- release_metadata
if: ${{ inputs.dry_run }}
env:
RELEASE_TAG: ${{ needs.release_metadata.outputs.tag }}
RELEASE_VERSION: ${{ needs.release_metadata.outputs.version }}
steps:
- name: Download installer artifacts
uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- name: List release assets
run: |
set -euo pipefail
assets=()
while IFS= read -r -d '' file; do
assets+=("$file")
done < <(find release-assets -type f -print0 | sort -z)
if [ "${#assets[@]}" -eq 0 ]; then
echo "No release assets were downloaded."
exit 1
fi
{
echo "## Desktop release dry run"
echo
echo "Version: $RELEASE_VERSION"
echo "Release tag: $RELEASE_TAG"
echo
echo "Built ${#assets[@]} asset(s). No GitHub Release was created or updated."
echo
echo "| Asset | Size |"
echo "| --- | ---: |"
for file in "${assets[@]}"; do
size=$(du -h "$file" | cut -f1)
echo "| $(basename "$file") | $size |"
done
} >> "$GITHUB_STEP_SUMMARY"