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