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