Open History to see the last commit
1name: Release Desktop
2
3on:
4 push:
5 tags:
6 - "v*.*.*"
7 workflow_dispatch:
8 inputs:
9 version:
10 description: "Release version (for example 1.2.3 or v1.2.3)"
11 required: true
12 type: string
13
14permissions:
15 contents: write
16 id-token: write
17
18jobs:
19 preflight:
20 name: Preflight
21 runs-on: ubuntu-24.04
22 timeout-minutes: 10
23 outputs:
24 version: ${{ steps.release_meta.outputs.version }}
25 tag: ${{ steps.release_meta.outputs.tag }}
26 is_prerelease: ${{ steps.release_meta.outputs.is_prerelease }}
27 make_latest: ${{ steps.release_meta.outputs.make_latest }}
28 ref: ${{ github.sha }}
29 steps:
30 - name: Checkout
31 uses: actions/checkout@v6
32
33 - id: release_meta
34 name: Resolve release version
35 shell: bash
36 run: |
37 if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
38 raw="${{ github.event.inputs.version }}"
39 else
40 raw="${GITHUB_REF_NAME}"
41 fi
42
43 version="${raw#v}"
44 if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
45 echo "Invalid release version: $raw" >&2
46 exit 1
47 fi
48
49 echo "version=$version" >> "$GITHUB_OUTPUT"
50 echo "tag=v$version" >> "$GITHUB_OUTPUT"
51 if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
52 echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
53 echo "make_latest=true" >> "$GITHUB_OUTPUT"
54 else
55 echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
56 echo "make_latest=false" >> "$GITHUB_OUTPUT"
57 fi
58
59 - name: Setup Bun
60 uses: oven-sh/setup-bun@v2
61 with:
62 bun-version-file: package.json
63
64 - name: Setup Node
65 uses: actions/setup-node@v6
66 with:
67 node-version-file: package.json
68
69 - name: Install dependencies
70 run: bun install --frozen-lockfile
71
72 - name: Lint
73 run: bun run lint
74
75 - name: Typecheck
76 run: bun run typecheck
77
78 - name: Test
79 run: bun run test
80
81 build:
82 name: Build ${{ matrix.label }}
83 needs: preflight
84 runs-on: ${{ matrix.runner }}
85 timeout-minutes: 30
86 strategy:
87 fail-fast: false
88 matrix:
89 include:
90 - label: macOS arm64
91 runner: macos-14
92 platform: mac
93 target: dmg
94 arch: arm64
95 - label: macOS x64
96 runner: macos-15-intel
97 platform: mac
98 target: dmg
99 arch: x64
100 - label: Linux x64
101 runner: ubuntu-24.04
102 platform: linux
103 target: AppImage
104 arch: x64
105 - label: Windows x64
106 runner: windows-2022
107 platform: win
108 target: nsis
109 arch: x64
110 steps:
111 - name: Checkout
112 uses: actions/checkout@v6
113 with:
114 ref: ${{ needs.preflight.outputs.ref }}
115 fetch-depth: 0
116
117 - name: Setup Bun
118 uses: oven-sh/setup-bun@v2
119 with:
120 bun-version-file: package.json
121
122 - name: Setup Node
123 uses: actions/setup-node@v6
124 with:
125 node-version-file: package.json
126
127 - name: Install dependencies
128 run: bun install --frozen-lockfile
129
130 - name: Align package versions to release version
131 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
132
133 - name: Build desktop artifact
134 shell: bash
135 env:
136 CSC_LINK: ${{ secrets.CSC_LINK }}
137 CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
138 APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
139 APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
140 APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
141 AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
142 AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
143 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
144 AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
145 AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
146 AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME }}
147 AZURE_TRUSTED_SIGNING_PUBLISHER_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_PUBLISHER_NAME }}
148 run: |
149 args=(
150 --platform "${{ matrix.platform }}"
151 --target "${{ matrix.target }}"
152 --arch "${{ matrix.arch }}"
153 --build-version "${{ needs.preflight.outputs.version }}"
154 --verbose
155 )
156
157 has_all() {
158 for value in "$@"; do
159 if [[ -z "$value" ]]; then
160 return 1
161 fi
162 done
163 return 0
164 }
165
166 if [[ "${{ matrix.platform }}" == "mac" ]]; then
167 if has_all "$CSC_LINK" "$CSC_KEY_PASSWORD" "$APPLE_API_KEY" "$APPLE_API_KEY_ID" "$APPLE_API_ISSUER"; then
168 key_path="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"
169 printf '%s' "$APPLE_API_KEY" > "$key_path"
170 export APPLE_API_KEY="$key_path"
171 echo "macOS signing enabled."
172 args+=(--signed)
173 else
174 echo "macOS signing disabled (missing one or more Apple signing secrets)."
175 fi
176 elif [[ "${{ matrix.platform }}" == "win" ]]; then
177 if has_all \
178 "$AZURE_TENANT_ID" \
179 "$AZURE_CLIENT_ID" \
180 "$AZURE_CLIENT_SECRET" \
181 "$AZURE_TRUSTED_SIGNING_ENDPOINT" \
182 "$AZURE_TRUSTED_SIGNING_ACCOUNT_NAME" \
183 "$AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME" \
184 "$AZURE_TRUSTED_SIGNING_PUBLISHER_NAME"; then
185 echo "Windows signing enabled (Azure Trusted Signing)."
186 args+=(--signed)
187 else
188 echo "Windows signing disabled (missing one or more Azure Trusted Signing secrets)."
189 fi
190 else
191 echo "Signing disabled for ${{ matrix.platform }}."
192 fi
193
194 bun run dist:desktop:artifact -- "${args[@]}"
195
196 - name: Collect release assets
197 shell: bash
198 run: |
199 set -euo pipefail
200 mkdir -p release-publish
201
202 shopt -s nullglob
203 for pattern in \
204 "release/*.dmg" \
205 "release/*.zip" \
206 "release/*.AppImage" \
207 "release/*.exe" \
208 "release/*.blockmap" \
209 "release/latest*.yml"; do
210 for file in $pattern; do
211 cp "$file" release-publish/
212 done
213 done
214
215 if [[ "${{ matrix.platform }}" == "mac" && "${{ matrix.arch }}" != "arm64" ]]; then
216 if [[ -f release-publish/latest-mac.yml ]]; then
217 mv release-publish/latest-mac.yml "release-publish/latest-mac-${{ matrix.arch }}.yml"
218 fi
219 fi
220
221 - name: Upload build artifacts
222 uses: actions/upload-artifact@v7
223 with:
224 name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
225 path: release-publish/*
226 if-no-files-found: error
227
228 publish_cli:
229 name: Publish CLI to npm
230 needs: [preflight, build]
231 runs-on: ubuntu-24.04
232 timeout-minutes: 10
233 steps:
234 - name: Checkout
235 uses: actions/checkout@v6
236 with:
237 ref: ${{ needs.preflight.outputs.ref }}
238
239 - name: Setup Bun
240 uses: oven-sh/setup-bun@v2
241 with:
242 bun-version-file: package.json
243
244 - name: Setup Node
245 uses: actions/setup-node@v6
246 with:
247 node-version-file: package.json
248 registry-url: https://registry.npmjs.org
249
250 - name: Install dependencies
251 run: bun install --frozen-lockfile
252
253 - name: Align package versions to release version
254 run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
255
256 - name: Build CLI package
257 run: bun run build --filter=@t3tools/web --filter=t3
258
259 - name: Publish CLI package
260 run: node apps/server/scripts/cli.ts publish --tag latest --app-version "${{ needs.preflight.outputs.version }}" --verbose
261
262 release:
263 name: Publish GitHub Release
264 needs: [preflight, build, publish_cli]
265 runs-on: ubuntu-24.04
266 timeout-minutes: 10
267 steps:
268 - name: Checkout
269 uses: actions/checkout@v6
270 with:
271 ref: ${{ needs.preflight.outputs.ref }}
272
273 - name: Setup Node
274 uses: actions/setup-node@v6
275 with:
276 node-version-file: package.json
277
278 - name: Download all desktop artifacts
279 uses: actions/download-artifact@v8
280 with:
281 pattern: desktop-*
282 merge-multiple: true
283 path: release-assets
284
285 - name: Merge macOS updater manifests
286 run: |
287 node scripts/merge-mac-update-manifests.ts \
288 release-assets/latest-mac.yml \
289 release-assets/latest-mac-x64.yml
290 rm -f release-assets/latest-mac-x64.yml
291
292 - name: Publish release
293 uses: softprops/action-gh-release@v2
294 with:
295 tag_name: ${{ needs.preflight.outputs.tag }}
296 target_commitish: ${{ needs.preflight.outputs.ref }}
297 name: T3 Code v${{ needs.preflight.outputs.version }}
298 generate_release_notes: true
299 prerelease: ${{ needs.preflight.outputs.is_prerelease }}
300 make_latest: ${{ needs.preflight.outputs.make_latest }}
301 files: |
302 release-assets/*.dmg
303 release-assets/*.zip
304 release-assets/*.AppImage
305 release-assets/*.exe
306 release-assets/*.blockmap
307 release-assets/latest*.yml
308 fail_on_unmatched_files: true
309
310 finalize:
311 name: Finalize release
312 needs: [preflight, release]
313 runs-on: ubuntu-24.04
314 timeout-minutes: 10
315 steps:
316 - id: app_token
317 name: Mint release app token
318 uses: actions/create-github-app-token@v2
319 with:
320 app-id: ${{ secrets.RELEASE_APP_ID }}
321 private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
322 owner: ${{ github.repository_owner }}
323
324 - name: Checkout
325 uses: actions/checkout@v6
326 with:
327 ref: main
328 fetch-depth: 0
329 token: ${{ steps.app_token.outputs.token }}
330 persist-credentials: true
331
332 - id: app_bot
333 name: Resolve GitHub App bot identity
334 env:
335 GH_TOKEN: ${{ steps.app_token.outputs.token }}
336 APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
337 run: |
338 user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
339 echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
340 echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
341
342 - name: Setup Bun
343 uses: oven-sh/setup-bun@v2
344 with:
345 bun-version-file: package.json
346
347 - name: Setup Node
348 uses: actions/setup-node@v6
349 with:
350 node-version-file: package.json
351
352 - id: update_versions
353 name: Update version strings
354 env:
355 RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
356 run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
357
358 - name: Format package.json files
359 if: steps.update_versions.outputs.changed == 'true'
360 run: bunx oxfmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json
361
362 - name: Refresh lockfile
363 if: steps.update_versions.outputs.changed == 'true'
364 run: bun install --lockfile-only --ignore-scripts
365
366 - name: Commit and push version bump
367 if: steps.update_versions.outputs.changed == 'true'
368 shell: bash
369 env:
370 RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
371 run: |
372 if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock; then
373 echo "No version changes to commit."
374 exit 0
375 fi
376
377 git config user.name "${{ steps.app_bot.outputs.name }}"
378 git config user.email "${{ steps.app_bot.outputs.email }}"
379
380 git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock
381 git commit -m "chore(release): prepare $RELEASE_TAG"
382 git push origin HEAD:main