upstream: adopt the clean half of the 2026-09-03 T3 batch (65 commits) #106
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Desktop macOS Preview | |
| on: | |
| pull_request: | |
| types: [labeled, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: desktop-macos-preview-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Build macOS Apple Silicon preview | |
| if: >- | |
| github.event.pull_request.head.repo.full_name == github.repository && | |
| contains(github.event.pull_request.labels.*.name, 'preview:mac') && | |
| (github.event.action != 'labeled' || github.event.label.name == 'preview:mac') | |
| runs-on: macos-26 | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| sparse-checkout: | | |
| /* | |
| !/.repos/ | |
| sparse-checkout-cone-mode: false | |
| - name: Setup Vite+ | |
| uses: voidzero-dev/setup-vp@v1 | |
| with: | |
| node-version-file: package.json | |
| cache: true | |
| run-install: false | |
| - name: Install desktop dependencies | |
| run: vp install --filter=@t3tools/desktop... --filter=t3... --filter=@t3tools/scripts... | |
| - name: Cache resource monitor | |
| id: resource_monitor_cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: native/resource-monitor/target/aarch64-apple-darwin/release/t3-resource-monitor | |
| key: resource-monitor-aarch64-apple-darwin-${{ hashFiles('native/resource-monitor/Cargo.lock', 'native/resource-monitor/Cargo.toml', 'native/resource-monitor/src/**') }} | |
| - name: Setup Rust | |
| if: steps.resource_monitor_cache.outputs.cache-hit != 'true' | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-apple-darwin | |
| - id: version | |
| name: Set preview version and public configuration | |
| shell: bash | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| set -euo pipefail | |
| base_version="$(node -p "require('./apps/desktop/package.json').version")" | |
| preview_version="${base_version}-pr.${PR_NUMBER}.${GITHUB_RUN_NUMBER}" | |
| node scripts/update-release-package-versions.ts "$preview_version" | |
| cp .env.example .env | |
| echo "version=$preview_version" >> "$GITHUB_OUTPUT" | |
| - id: build | |
| name: Build unsigned macOS DMG | |
| shell: bash | |
| env: | |
| T3CODE_DESKTOP_REUSE_RESOURCE_MONITOR: ${{ steps.resource_monitor_cache.outputs.cache-hit == 'true' }} | |
| PREVIEW_VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| set -euo pipefail | |
| vp run dist:desktop:artifact \ | |
| --platform mac \ | |
| --target dmg \ | |
| --arch arm64 \ | |
| --build-version "$PREVIEW_VERSION" \ | |
| --verbose | |
| shopt -s nullglob | |
| dmg_files=(release/*.dmg) | |
| if (( ${#dmg_files[@]} != 1 )); then | |
| printf 'Expected one DMG, found %s.\n' "${#dmg_files[@]}" >&2 | |
| exit 1 | |
| fi | |
| printf 'dmg_name=%s\n' "$(basename "${dmg_files[0]}")" >> "$GITHUB_OUTPUT" | |
| - id: upload | |
| name: Upload macOS DMG | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| path: release/*.dmg | |
| if-no-files-found: error | |
| archive: false | |
| overwrite: true | |
| retention-days: 7 | |
| - name: Comment download link | |
| uses: actions/github-script@v8 | |
| env: | |
| ARTIFACT_URL: ${{ steps.upload.outputs.artifact-url }} | |
| DMG_NAME: ${{ steps.build.outputs.dmg_name }} | |
| HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| PREVIEW_VERSION: ${{ steps.version.outputs.version }} | |
| with: | |
| script: | | |
| const { data: pullRequest } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.payload.pull_request.number, | |
| }); | |
| if (pullRequest.head.sha !== process.env.HEAD_SHA) { | |
| core.info("Skipping the outdated macOS preview comment."); | |
| return; | |
| } | |
| const marker = "<!-- desktop-macos-preview -->"; | |
| const body = [ | |
| marker, | |
| "### macOS preview", | |
| "", | |
| `[Download Apple Silicon DMG](${process.env.ARTIFACT_URL})`, | |
| "", | |
| `Version: ${process.env.PREVIEW_VERSION}`, | |
| `Commit: ${process.env.HEAD_SHA.slice(0, 7)}`, | |
| "", | |
| "Unsigned build. Clear quarantine before opening:", | |
| "```sh", | |
| `xattr -d com.apple.quarantine ~/Downloads/${process.env.DMG_NAME}`, | |
| "```", | |
| "", | |
| "The download requires GitHub access and expires after 7 days.", | |
| ].join("\n"); | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| per_page: 100, | |
| }); | |
| const existing = comments.find((comment) => comment.body?.includes(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| body, | |
| }); | |
| } |