diff --git a/.github/actions/boopface-key/action.yml b/.github/actions/boopface-key/action.yml new file mode 100644 index 000000000000..b1919a2727f2 --- /dev/null +++ b/.github/actions/boopface-key/action.yml @@ -0,0 +1,30 @@ +name: BoopFace read key +description: Gives git the read-only deploy key for the private BoopFace fork. Run before any install. +inputs: + key: + description: The private key from the BOOPFACE_READ_KEY repository secret. + required: true +runs: + using: composite + steps: + - name: Use the BoopFace read key + shell: bash + env: + BOOPFACE_READ_KEY: ${{ inputs.key }} + run: | + if [ -z "$BOOPFACE_READ_KEY" ]; then + echo "::error::BOOPFACE_READ_KEY is empty. Add the read-only deploy key for CarsonJF/boopface-fork as the BOOPFACE_READ_KEY repository secret, then re-run this job." + exit 1 + fi + key="$RUNNER_TEMP/boopface-read-key" + (umask 077; printf '%s\n' "$BOOPFACE_READ_KEY" | tr -d '\r' > "$key") + chmod 600 "$key" + if [ "$RUNNER_OS" = "Windows" ]; then + # Git for Windows hands ssh a Windows path, while bash sees /d/... + key="$(cygpath -w "$key")" + fi + echo "GIT_SSH_COMMAND=ssh -i \"$key\" -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" >> "$GITHUB_ENV" + # pnpm records the fork's repo over HTTPS even for a git+ssh specifier, + # so map that one URL to SSH. The rewrite is scoped to the fork: pushes + # to t3code keep using the job's own credentials. + git config --global url."git@github.com:CarsonJF/boopface-fork.git".insteadOf "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/CarsonJF/boopface-fork.git" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40c84a71ad84..658d90a9e89c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,6 +84,11 @@ jobs: exit 1 fi + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: ./.github/actions/setup-ci-deps with: @@ -159,6 +164,11 @@ jobs: echo "$?" > "$RUNNER_TEMP/apt-status" ) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null & + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: ./.github/actions/setup-ci-deps with: @@ -312,6 +322,11 @@ jobs: echo "$?" > "$RUNNER_TEMP/apt-status" ) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null & + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: ./.github/actions/setup-ci-deps with: @@ -387,6 +402,11 @@ jobs: !/apps/mobile/modules/t3-terminal/Vendor/**/*.a sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: ./.github/actions/setup-ci-deps with: @@ -457,6 +477,11 @@ jobs: id: changes uses: ./.github/actions/ci-changes + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ if: steps.changes.outputs.test_server != 'false' uses: ./.github/actions/setup-ci-deps @@ -608,6 +633,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 with: @@ -642,6 +672,11 @@ jobs: !/apps/mobile/modules/t3-terminal/Vendor/**/*.a sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: ./.github/actions/setup-ci-deps with: diff --git a/.github/workflows/custom-nightly.yml b/.github/workflows/custom-nightly.yml new file mode 100644 index 000000000000..519adfb0e120 --- /dev/null +++ b/.github/workflows/custom-nightly.yml @@ -0,0 +1,791 @@ +# Fork-only pipeline: rebase `custom` onto the newest upstream nightly and ship +# Windows x64, macOS (arm64 + x64) and Android builds of it. See CUSTOM.md. +# Upstream's release workflows are disabled on this fork; this file must stay +# the only active workflow. +name: Custom nightly + +on: + schedule: + - cron: "17 */3 * * *" + # Publish now without gh auth: `git tag -f publish-custom-nightly && git push -f + # origin publish-custom-nightly`. The run checks out `custom`, not the tag. + push: + tags: + - publish-custom-nightly + workflow_dispatch: + inputs: + upstream_tag: + description: "Upstream nightly tag to build (default: newest published)" + required: false + type: string + force: + description: "Rebuild and replace the release even if one exists for this tag" + required: false + default: false + type: boolean + mac_runner: + description: "macOS runner label; macos-15-intel when macos-26 (arm64) has no capacity" + required: false + default: macos-26 + type: string + +concurrency: + group: custom-nightly + cancel-in-progress: false + +permissions: + contents: read + +env: + UPSTREAM_REPO: pingdotgg/t3code + BRANCH: custom + +jobs: + # mode: full = rebase, check, push, build every platform, (re)create the release. + # repair = the release exists but lacks some platform's assets: build only + # those at the release tag's commit and attach them. + # skip = the release has every platform's assets. + prepare: + name: Rebase and check + if: github.repository != 'pingdotgg/t3code' + runs-on: ubuntu-latest + timeout-minutes: 45 + permissions: + contents: read + actions: write + outputs: + mode: ${{ steps.resolve.outputs.mode }} + skip: ${{ steps.resolve.outputs.mode == 'skip' }} + need_win: ${{ steps.resolve.outputs.need_win }} + need_mac: ${{ steps.resolve.outputs.need_mac }} + need_android: ${{ steps.resolve.outputs.need_android }} + need_linux: ${{ steps.resolve.outputs.need_linux }} + upstream_tag: ${{ steps.resolve.outputs.upstream_tag }} + version: ${{ steps.resolve.outputs.version }} + release_tag: ${{ steps.resolve.outputs.release_tag }} + sha: ${{ steps.budget.outputs.sha || steps.rebase.outputs.sha || steps.resolve.outputs.repair_sha }} + failure: ${{ steps.rebase.outputs.failure || steps.checks.outputs.failure }} + env: + GH_TOKEN: ${{ github.token }} + steps: + - id: resolve + name: Resolve newest upstream nightly + env: + INPUT_TAG: ${{ inputs.upstream_tag }} + FORCE: ${{ inputs.force }} + run: | + set -euo pipefail + tag="${INPUT_TAG:-}" + if [[ -z "$tag" ]]; then + # Published releases only, so the Linux CLI archive embedded below exists. + tag="$(gh release list -R "$UPSTREAM_REPO" --exclude-drafts --limit 40 --json tagName -q '.[].tagName' \ + | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+-nightly\.[0-9]{8}\.[0-9]+$' | head -n 1)" + fi + [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-nightly\.[0-9]{8}\.[0-9]+$ ]] || { echo "Bad upstream tag: '$tag'" >&2; exit 1; } + release_tag="${tag}-custom" + mode=full need_win=true need_mac=true need_android=true need_linux=true repair_sha= + if [[ "$FORCE" != "true" ]] && assets="$(gh release view "$release_tag" -R "$GITHUB_REPOSITORY" --json assets -q '.assets[].name' 2>/dev/null)"; then + # Each platform counts as published once its feed manifest (desktop), APK, or + # CLI archive and checksums (Linux server/WSL runtime) is attached. + grep -qx 'nightly.yml' <<<"$assets" && need_win=false + grep -qx 'nightly-mac.yml' <<<"$assets" && need_mac=false + grep -q '\.apk$' <<<"$assets" && need_android=false + if grep -qE '^t3-.*-linux-x64\.tar\.gz$' <<<"$assets" && grep -qx 'SHA256SUMS' <<<"$assets"; then + need_linux=false + fi + if [[ "$need_win$need_mac$need_android$need_linux" == falsefalsefalsefalse ]]; then + mode=skip + echo "Release $release_tag has every platform; nothing to do." + elif [[ "$need_linux" == true ]]; then + # The Linux CLI is this fork's own updater, baked to read this repository. A repair + # at the old tag would publish a binary that still updates from upstream, so rebuild + # the whole release at the rebased HEAD the first time the archive is missing. + echo "Release $release_tag has no custom Linux CLI; rebuilding the full release." + else + mode=repair + repair_sha="$(gh api "repos/$GITHUB_REPOSITORY/commits/$release_tag" -q .sha)" + echo "Release $release_tag is missing: win=$need_win mac=$need_mac android=$need_android; rebuilding those at $repair_sha." + fi + fi + { + echo "upstream_tag=$tag" + echo "version=${tag#v}" + echo "release_tag=$release_tag" + echo "mode=$mode" + echo "need_win=$need_win" + echo "need_mac=$need_mac" + echo "need_android=$need_android" + echo "need_linux=$need_linux" + echo "repair_sha=$repair_sha" + } >> "$GITHUB_OUTPUT" + + # Inherited upstream workflows would run (or queue forever on upstream's + # runners) when this job pushes. Re-disable any that upstream adds. + - name: Keep inherited workflows disabled + if: steps.resolve.outputs.mode == 'full' + run: | + set -euo pipefail + gh workflow list -R "$GITHUB_REPOSITORY" --all --json path,state \ + -q '.[] | select(.state == "active" and .path != ".github/workflows/custom-nightly.yml") | .path' \ + | while read -r path; do + echo "Disabling $path" + gh workflow disable "$(basename "$path")" -R "$GITHUB_REPOSITORY" + done + + - name: Checkout + if: steps.resolve.outputs.mode == 'full' + uses: actions/checkout@v6 + with: + ref: ${{ env.BRANCH }} + fetch-depth: 0 + ssh-key: ${{ secrets.CUSTOM_NIGHTLY_DEPLOY_KEY }} + sparse-checkout: | + /* + !/.repos/ + sparse-checkout-cone-mode: false + + # custom = + our commits. Our commits are whatever + # custom has that upstream main does not; nothing is pushed on conflict. + - id: rebase + name: Rebase onto the upstream nightly + if: steps.resolve.outputs.mode == 'full' + env: + TAG: ${{ steps.resolve.outputs.upstream_tag }} + run: | + set -euo pipefail + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config rerere.enabled true + git config rerere.autoupdate true + # sparse-checkout makes a blob:none clone; the rebase's batched lazy blob + # fetch from origin then fails with "not our ref". Fetch real blobs first. + git fetch --refetch --no-filter --no-tags origin "$BRANCH" + git remote add upstream "/${UPSTREAM_REPO}.git" + git fetch --no-tags upstream main "+refs/tags/${TAG}:refs/tags/${TAG}" + tag_sha="$(git rev-parse "${TAG}^{commit}")" + old_tip="$(git rev-parse HEAD)" + old_base="$(git merge-base HEAD upstream/main)" + echo "old_tip=$old_tip" >> "$GITHUB_OUTPUT" + echo "Our commits:"; git log --oneline "$old_base..HEAD" + # The budget is a measured snapshot, regenerated after the rebase, so a conflict + # on it alone takes upstream's side (ours, mid-rebase) and moves on. + budget=apps/server/src/provider/agentContextBudget.json + rebase_ok=true + git rebase --onto "$tag_sha" "$old_base" HEAD || rebase_ok=false + while [[ "$rebase_ok" == false ]]; do + [[ "$(git diff --name-only --diff-filter=U)" == "$budget" ]] || break + git checkout --ours -- "$budget" + git add "$budget" + if GIT_EDITOR=true git rebase --continue; then rebase_ok=true; fi + done + if [[ "$rebase_ok" == false ]]; then + { + echo "failure<> "$GITHUB_OUTPUT" + git rebase --abort + exit 1 + fi + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + echo "tag_sha=$tag_sha" >> "$GITHUB_OUTPUT" + + - name: Setup Vite+ + if: steps.resolve.outputs.mode == 'full' + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1 + with: + node-version-file: package.json + cache: true + run-install: false + + - name: Use the BoopFace read key + if: steps.resolve.outputs.mode == 'full' + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + + - id: budget + name: Regenerate the agent context budget + if: steps.resolve.outputs.mode == 'full' + run: | + set -euo pipefail + vp install + (cd apps/server && UPDATE_AGENT_CONTEXT_BUDGET=1 vp test run src/provider/AgentContextBudget.test.ts) + if ! git diff --quiet -- apps/server/src/provider/agentContextBudget.json; then + git add apps/server/src/provider/agentContextBudget.json + git commit -m "chore(server): regenerate the agent context budget after rebase" + fi + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + + # Format, lint, knip, typecheck of affected packages, and tests beside + # our changed files, measured against the upstream nightly commit. + - id: checks + name: Focused checks for our commits + if: steps.resolve.outputs.mode == 'full' + env: + TAG_SHA: ${{ steps.rebase.outputs.tag_sha }} + run: | + set -euo pipefail + vp install + # Web tests beside our changes run in headless Chromium. + node apps/web/node_modules/playwright/cli.js install --with-deps --only-shell chromium + if ! vp run check:changed "$TAG_SHA"; then + echo "failure=Focused checks (vp run check:changed) failed after rebasing onto ${TAG_SHA}." >> "$GITHUB_OUTPUT" + exit 1 + fi + + - name: Push custom and mirror main + if: steps.resolve.outputs.mode == 'full' + env: + OLD_TIP: ${{ steps.rebase.outputs.old_tip }} + run: | + set -euo pipefail + # The BoopFace read key exports GIT_SSH_COMMAND for later steps and would override + # the checkout's deploy key, so pushes authenticate with the deploy key instead. + unset GIT_SSH_COMMAND + git push --force-with-lease="refs/heads/${BRANCH}:${OLD_TIP}" origin "HEAD:refs/heads/${BRANCH}" + git push --force origin "refs/remotes/upstream/main:refs/heads/main" + + # The Linux CLI is both the server runtime and the WSL backend in the Windows + # installer. Building it here (rather than reusing upstream's) puts the custom + # server commits on every Linux environment, and bakes in the fork's update feed. + build_linux: + name: Build Linux x64 CLI + needs: [prepare] + if: >- + needs.prepare.outputs.mode != 'skip' && + (needs.prepare.outputs.need_linux == 'true' || needs.prepare.outputs.need_win == 'true') + runs-on: ubuntu-latest + timeout-minutes: 90 + env: + VERSION: ${{ needs.prepare.outputs.version }} + # The web client's "Update everything" lookup follows this repository. + T3CODE_DESKTOP_UPDATE_REPOSITORY: ${{ github.repository }} + T3CODE_TELEMETRY_CHANNEL: dev + T3CODE_CLERK_PUBLISHABLE_KEY: ${{ vars.T3CODE_CLERK_PUBLISHABLE_KEY }} + T3CODE_CLERK_JWT_TEMPLATE: ${{ vars.T3CODE_CLERK_JWT_TEMPLATE }} + T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.T3CODE_CLERK_CLI_OAUTH_CLIENT_ID }} + T3CODE_RELAY_URL: ${{ vars.T3CODE_RELAY_URL }} + steps: + - name: Checkout + env: + SHA: ${{ needs.prepare.outputs.sha }} + GIT_TERMINAL_PROMPT: "0" + run: | + set -euo pipefail + git init . + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --no-tags --depth=1 origin "$SHA" + git sparse-checkout set --no-cone '/*' '!/.repos/' + git checkout --detach FETCH_HEAD + + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1 + with: + node-version-file: package.json + cache: false + run-install: false + + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + + - name: Install + run: vp install --filter=t3... --filter=@t3tools/web... --filter=@t3tools/scripts... + + - name: Build JS bundle and web client + run: | + set -euo pipefail + node scripts/update-release-package-versions.ts "$VERSION" + vp run --filter @t3tools/web build + node apps/server/scripts/cli.ts build + node scripts/apply-web-brand-assets.ts nightly apps/server/dist/client + + - name: Build resource monitor + run: cargo build --locked --release --manifest-path native/resource-monitor/Cargo.toml + + - name: Build CLI single-executable + run: node apps/server/scripts/cli.ts build-exe --verbose + + - name: Package Linux CLI archive + run: | + set -euo pipefail + command -v patchelf || { sudo apt-get update && sudo apt-get install -y patchelf; } + mkdir -p cli-resource-monitor/linux-x64 + cp native/resource-monitor/target/release/t3-resource-monitor cli-resource-monitor/linux-x64/ + node scripts/build-cli-archive.ts \ + --platform linux --arch x64 --version "$VERSION" \ + --resource-monitor-dir "$PWD/cli-resource-monitor" \ + --output-dir release-cli + (cd release-cli && sha256sum t3-*.tar.gz > SHA256SUMS) + node scripts/smoke-cli-archive.ts --archive release-cli/*.tar.gz --expect-version "$VERSION" + ls -la release-cli + + - uses: actions/upload-artifact@v7 + with: + name: cli-linux-x64 + path: release-cli/* + if-no-files-found: error + retention-days: 7 + + build: + name: Build Windows x64 + needs: [prepare, build_linux] + if: needs.prepare.outputs.mode != 'skip' && needs.prepare.outputs.need_win == 'true' + runs-on: windows-latest + timeout-minutes: 90 + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ needs.prepare.outputs.version }} + # Feed baked into app-update.yml: this fork's releases, nightly channel. + T3CODE_DESKTOP_UPDATE_REPOSITORY: ${{ github.repository }} + T3CODE_TELEMETRY_CHANNEL: dev + # Optional T3 Connect public config (repo variables); unset disables it. + T3CODE_CLERK_PUBLISHABLE_KEY: ${{ vars.T3CODE_CLERK_PUBLISHABLE_KEY }} + T3CODE_CLERK_JWT_TEMPLATE: ${{ vars.T3CODE_CLERK_JWT_TEMPLATE }} + T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.T3CODE_CLERK_CLI_OAUTH_CLIENT_ID }} + T3CODE_RELAY_URL: ${{ vars.T3CODE_RELAY_URL }} + defaults: + run: + shell: bash + steps: + # actions/checkout's cleanup trips over the .repos gitlinks on Windows. + - name: Checkout + env: + SHA: ${{ needs.prepare.outputs.sha }} + GIT_TERMINAL_PROMPT: "0" + run: | + set -euo pipefail + git init . + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --no-tags --depth=1 origin "$SHA" + git sparse-checkout set --no-cone '/*' '!/.repos/' + git -c checkout.workers=0 checkout --detach FETCH_HEAD + + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1 + with: + node-version-file: package.json + cache: false + run-install: false + + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + + - name: Install + run: vp install --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts... + + - name: Build JS bundle + run: | + set -euo pipefail + node scripts/update-release-package-versions.ts "$VERSION" + vp run build:desktop + + # The WSL backend runs the Linux CLI inside the distro; use the archive this + # pipeline just built from the same commit so WSL gets the custom server too. + - name: Fetch custom Linux CLI archive for WSL + uses: actions/download-artifact@v8 + with: + name: cli-linux-x64 + path: wsl-runtime + + - name: Build installer + run: | + set -euo pipefail + vp run dist:desktop:artifact --platform win --target nsis --arch x64 \ + --build-version "$VERSION" --skip-build --keep-stage --verbose \ + --wsl-runtime "$(cygpath -w "$(ls "$PWD"/wsl-runtime/t3-*-linux-x64.tar.gz)")" + tmp="$(cygpath -u "$(node -p 'require("os").tmpdir()')")" + feed="$(ls "$tmp"/t3code-desktop-win-stage-*/app/dist/win-unpacked/resources/app-update.yml | head -n 1)" + cat "$feed" + grep -qx "owner: ${GITHUB_REPOSITORY%/*}" "$feed" + # electron-updater verifies update signatures only when publisherName is set. + if grep -q publisherName "$feed"; then echo "Unsigned build must not set publisherName" >&2; exit 1; fi + ls -la release + + - uses: actions/upload-artifact@v7 + with: + name: desktop-win-x64 + path: | + release/*.exe + release/*.blockmap + release/nightly.yml + if-no-files-found: error + retention-days: 7 + + # Signed with a stable self-signed identity (secret CUSTOM_MAC_SIGNING_P12), + # not ad hoc: Squirrel.Mac only installs an update whose signature satisfies + # the running app's designated requirement, and an ad-hoc requirement is a + # per-build hash. No Apple account, so Gatekeeper still needs one manual open. + build_mac: + name: Build macOS arm64 + x64 + needs: [prepare] + if: needs.prepare.outputs.mode != 'skip' && needs.prepare.outputs.need_mac == 'true' + # Builds both arches on one machine, so an Intel runner works when arm64 runners are scarce. + runs-on: ${{ inputs.mac_runner || 'macos-26' }} + timeout-minutes: 120 + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ needs.prepare.outputs.version }} + T3CODE_DESKTOP_UPDATE_REPOSITORY: ${{ github.repository }} + T3CODE_TELEMETRY_CHANNEL: dev + T3CODE_CLERK_PUBLISHABLE_KEY: ${{ vars.T3CODE_CLERK_PUBLISHABLE_KEY }} + T3CODE_CLERK_JWT_TEMPLATE: ${{ vars.T3CODE_CLERK_JWT_TEMPLATE }} + T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.T3CODE_CLERK_CLI_OAUTH_CLIENT_ID }} + T3CODE_RELAY_URL: ${{ vars.T3CODE_RELAY_URL }} + # The unsigned build path keeps CSC_NAME/CSC_KEYCHAIN; electron-builder signs with them. + CSC_NAME: T3 Code Custom Build (CarsonJF) + steps: + - name: Checkout + env: + SHA: ${{ needs.prepare.outputs.sha }} + GIT_TERMINAL_PROMPT: "0" + run: | + set -euo pipefail + git init . + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --no-tags --depth=1 origin "$SHA" + git sparse-checkout set --no-cone '/*' '!/.repos/' + git checkout --detach FETCH_HEAD + + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1 + with: + node-version-file: package.json + cache: false + run-install: false + + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + + - name: Install + run: vp install --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts... + + - name: Rust targets for the resource monitor + run: rustup target add aarch64-apple-darwin x86_64-apple-darwin + + - name: Build JS bundle + run: | + set -euo pipefail + node scripts/update-release-package-versions.ts "$VERSION" + vp run build:desktop + + - name: Import signing identity + timeout-minutes: 5 + env: + P12: ${{ secrets.CUSTOM_MAC_SIGNING_P12 }} + P12_PASSWORD: ${{ secrets.CUSTOM_MAC_SIGNING_PASSWORD }} + run: | + set -euo pipefail + keychain="$RUNNER_TEMP/custom-signing.keychain-db" + kc_pass="$(openssl rand -hex 16)" + printf '%s' "$P12" | base64 -D > "$RUNNER_TEMP/signing.p12" + security create-keychain -p "$kc_pass" "$keychain" + security set-keychain-settings -lut 21600 "$keychain" + security unlock-keychain -p "$kc_pass" "$keychain" + security import "$RUNNER_TEMP/signing.p12" -k "$keychain" -P "$P12_PASSWORD" -f pkcs12 -T /usr/bin/codesign + rm "$RUNNER_TEMP/signing.p12" + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$kc_pass" "$keychain" >/dev/null + security list-keychains -d user -s "$keychain" $(security list-keychains -d user | tr -d '"') + # A self-signed identity is listed as valid only once its cert is trusted for code signing. + security find-certificate -c "$CSC_NAME" -p "$keychain" > "$RUNNER_TEMP/signing.pem" + sudo security add-trusted-cert -d -r trustRoot -p codeSign -k /Library/Keychains/System.keychain "$RUNNER_TEMP/signing.pem" + security find-identity -v -p codesigning "$keychain" + security find-identity -v -p codesigning "$keychain" | grep -qF "\"$CSC_NAME\"" + sha1="$(openssl x509 -in "$RUNNER_TEMP/signing.pem" -noout -fingerprint -sha1 | cut -d= -f2 | tr -d : | tr 'A-F' 'a-f')" + echo "CSC_KEYCHAIN=$keychain" >> "$GITHUB_ENV" + echo "SIGNING_SHA1=$sha1" >> "$GITHUB_ENV" + + # electron-builder's default entitlements plus the camera/microphone ones + # upstream's signed build claims (scripts/build-desktop-artifact.ts). + - name: Entitlements + run: | + cat > apps/desktop/resources/entitlements.mac.plist <<'EOF' + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.disable-library-validation + + com.apple.security.device.camera + + com.apple.security.device.audio-input + + + + EOF + plutil -lint apps/desktop/resources/entitlements.mac.plist + + - name: Build dmg and zip + run: | + set -euo pipefail + tmp="$(node -p 'require("os").tmpdir()')" + for arch in arm64 x64; do + vp run dist:desktop:artifact --platform mac --target dmg --arch "$arch" \ + --build-version "$VERSION" --skip-build --keep-stage --verbose \ + --output-dir "$PWD/release-$arch" + stage="$(ls -dt "$tmp"/t3code-desktop-mac-stage-* | head -n 1)" + app="$(ls -d "$stage"/app/dist/mac*/*.app | head -n 1)" + feed="$app/Contents/Resources/app-update.yml" + cat "$feed" + grep -qx "owner: ${GITHUB_REPOSITORY%/*}" "$feed" + if grep -q publisherName "$feed"; then echo "Unexpected publisherName" >&2; exit 1; fi + codesign --verify --deep --strict --verbose=2 "$app" + requirement="$(codesign -d -r- "$app" 2>&1)" + echo "$requirement" + # Updates install only if every build has this same certificate-based requirement. + grep -q "H\"$SIGNING_SHA1\"" <<<"$requirement" || { echo "Designated requirement is not pinned to the signing cert" >&2; exit 1; } + codesign -d --entitlements - "$app" + lipo -archs "$app/Contents/MacOS/"* + ls -la "release-$arch" + done + + - name: Collect release assets + run: | + set -euo pipefail + node scripts/merge-update-manifests.ts --platform mac release-arm64/nightly-mac.yml release-x64/nightly-mac.yml + mkdir release-mac + cp release-arm64/*.dmg release-arm64/*.zip release-arm64/*.blockmap release-arm64/nightly-mac.yml release-mac/ + cp release-x64/*.dmg release-x64/*.zip release-x64/*.blockmap release-mac/ + cat release-mac/nightly-mac.yml + ls -la release-mac + + - uses: actions/upload-artifact@v7 + with: + name: desktop-mac + path: release-mac/* + if-no-files-found: error + retention-days: 7 + + # APP_VARIANT=preview: package com.t3tools.t3code.preview and scheme + # t3code-preview, so it installs beside the store app (com.t3tools.t3code, + # signed by upstream). OTA updates are off; they would pull upstream's JS. + build_android: + name: Build Android APK + needs: [prepare] + if: needs.prepare.outputs.mode != 'skip' && needs.prepare.outputs.need_android == 'true' + runs-on: ubuntu-latest + timeout-minutes: 90 + env: + VERSION: ${{ needs.prepare.outputs.version }} + APP_VARIANT: preview + MOBILE_VERSION_POLICY: appVersion + T3CODE_MOBILE_UPDATES_ENABLED: "0" + EXPO_NO_GIT_STATUS: "1" + EXPO_NO_TELEMETRY: "1" + NODE_OPTIONS: --max-old-space-size=8192 + T3CODE_CLERK_PUBLISHABLE_KEY: ${{ vars.T3CODE_CLERK_PUBLISHABLE_KEY }} + T3CODE_CLERK_JWT_TEMPLATE: ${{ vars.T3CODE_CLERK_JWT_TEMPLATE }} + T3CODE_CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.T3CODE_CLERK_CLI_OAUTH_CLIENT_ID }} + T3CODE_RELAY_URL: ${{ vars.T3CODE_RELAY_URL }} + steps: + - name: Free disk space + run: sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/.ghcup /opt/hostedtoolcache/CodeQL || true + + - name: Checkout + env: + SHA: ${{ needs.prepare.outputs.sha }} + GIT_TERMINAL_PROMPT: "0" + run: | + set -euo pipefail + git init . + git remote add origin "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" + git fetch --no-tags --depth=1 origin "$SHA" + git sparse-checkout set --no-cone '/*' '!/.repos/' + git checkout --detach FETCH_HEAD + + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1 + with: + node-version-file: package.json + cache: false + run-install: false + + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + + - name: Install + run: vp install --filter=@t3tools/mobile... --filter=@t3tools/scripts... + + - uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 17 + + - uses: gradle/actions/setup-gradle@v5 + + - name: Prebuild native project + working-directory: apps/mobile + run: | + set -euo pipefail + vp exec expo prebuild --clean --platform android --no-install + # Monotonic per nightly (vX.Y.Z-nightly.YYYYMMDD.N) so each APK installs over the last. + [[ "$VERSION" =~ -nightly\.[0-9]{2}([0-9]{6})\.([0-9]+)$ ]] + code=$(( 10#${BASH_REMATCH[1]} * 100 + 10#${BASH_REMATCH[2]} )) + sed -i -E "s/versionCode [0-9]+/versionCode ${code}/" android/app/build.gradle + grep -nE 'applicationId|versionCode|versionName' android/app/build.gradle + + - name: Build release APK + working-directory: apps/mobile/android + run: ./gradlew app:assembleRelease -PreactNativeArchitectures=arm64-v8a --no-daemon + + # The template signs release builds with the debug key; re-sign with the + # fork's keystore so every nightly installs over the previous one. + - name: Sign APK + env: + KEYSTORE: ${{ secrets.CUSTOM_ANDROID_KEYSTORE }} + KEYSTORE_PASSWORD: ${{ secrets.CUSTOM_ANDROID_KEYSTORE_PASSWORD }} + run: | + set -euo pipefail + tools="$(ls -d "$ANDROID_HOME"/build-tools/* | sort -V | tail -n 1)" + printf '%s' "$KEYSTORE" | base64 -d > "$RUNNER_TEMP/release.p12" + mkdir release-android + apk="release-android/T3-Code-Custom-${VERSION}-android-arm64.apk" + "$tools/apksigner" sign --ks "$RUNNER_TEMP/release.p12" --ks-type PKCS12 --ks-key-alias t3code-custom \ + --ks-pass env:KEYSTORE_PASSWORD --key-pass env:KEYSTORE_PASSWORD \ + --out "$apk" apps/mobile/android/app/build/outputs/apk/release/app-release.apk + rm "$RUNNER_TEMP/release.p12" + certs="$("$tools/apksigner" verify --print-certs "$apk")" + echo "$certs" + grep -q "SHA-256 digest: 773d0f1d9d99d4e8afd1da8abd0637a3eac49083aebd2b717e92040ac29855e8" <<<"$certs" + "$tools/aapt2" dump badging "$apk" | head -n 3 + ls -la release-android + + - uses: actions/upload-artifact@v7 + with: + name: mobile-android + path: release-android/*.apk + if-no-files-found: error + retention-days: 7 + + # Attaches whatever platforms built. A platform that failed is retried by the + # next scheduled run (repair mode) until a newer upstream nightly supersedes it. + publish: + name: Publish release + needs: [prepare, build, build_linux, build_mac, build_android] + if: >- + always() && needs.prepare.result == 'success' && needs.prepare.outputs.mode != 'skip' && + (needs.build.result == 'success' || needs.build_linux.result == 'success' || + needs.build_mac.result == 'success' || needs.build_android.result == 'success') + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: write + issues: write + env: + GH_TOKEN: ${{ github.token }} + MODE: ${{ needs.prepare.outputs.mode }} + RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }} + UPSTREAM_TAG: ${{ needs.prepare.outputs.upstream_tag }} + VERSION: ${{ needs.prepare.outputs.version }} + SHA: ${{ needs.prepare.outputs.sha }} + steps: + - uses: actions/download-artifact@v8 + with: + path: dist + merge-multiple: true + + - name: Verify feed manifests + run: | + set -euo pipefail + shopt -s nullglob + for feed in dist/*.yml; do + cat "$feed" + grep -qx "version: '\?${VERSION}'\?" "$feed" + for url in $(sed -n 's/^ *- url: //p' "$feed"); do test -f "dist/$url"; done + done + (cd dist && sha256sum ./*) + + # The tag is pushed with the deploy key: GITHUB_TOKEN may not create refs + # to commits that change workflow files. + - name: Checkout + if: env.MODE == 'full' + uses: actions/checkout@v6 + with: + ref: ${{ needs.prepare.outputs.sha }} + path: repo + ssh-key: ${{ secrets.CUSTOM_NIGHTLY_DEPLOY_KEY }} + sparse-checkout: /CUSTOM.md + sparse-checkout-cone-mode: false + + - name: Create or update release + run: | + set -euo pipefail + if [[ "$MODE" == "full" ]]; then + if gh release view "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then + gh release delete "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --cleanup-tag --yes + fi + git -C repo tag -f "$RELEASE_TAG" "$SHA" + git -C repo push -f origin "refs/tags/$RELEASE_TAG" + gh release create "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --verify-tag --prerelease --latest=false \ + --title "T3 Code Nightly ${VERSION} + custom (${SHA:0:12})" --notes "Publishing..." dist/* + else + # Binaries before manifests, so no updater sees a feed whose files are missing. + find dist -maxdepth 1 -type f ! -name '*.yml' -print0 | xargs -0 gh release upload "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --clobber + find dist -maxdepth 1 -type f -name '*.yml' -print0 | xargs -0 -r gh release upload "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --clobber + fi + assets="$(gh release view "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --json assets -q '.assets[].name')" + platforms=() + grep -qx 'nightly.yml' <<<"$assets" && platforms+=("Windows x64") + grep -qx 'nightly-mac.yml' <<<"$assets" && platforms+=("macOS arm64 + x64") + grep -q '\.apk$' <<<"$assets" && platforms+=("Android arm64") + grep -qE '^t3-.*-linux-x64\.tar\.gz$' <<<"$assets" && platforms+=("Linux x64 CLI") + list="$(IFS=,; echo "${platforms[*]}" | sed 's/,/, /g')" + notes="Upstream nightly [${UPSTREAM_TAG}](https://github.com/${UPSTREAM_REPO}/releases/tag/${UPSTREAM_TAG}) plus the commits on \`custom\` (${SHA:0:12}). Platforms: ${list}. Not notarized or store-signed; see CUSTOM.md to install." + gh release edit "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --notes "$notes" + + - name: Close failure issue + # A build GitHub never scheduled is cancelled, not failed; keep the issue open for it. + if: >- + needs.build.result != 'failure' && needs.build.result != 'cancelled' && + needs.build_linux.result != 'failure' && needs.build_linux.result != 'cancelled' && + needs.build_mac.result != 'failure' && needs.build_mac.result != 'cancelled' && + needs.build_android.result != 'failure' && needs.build_android.result != 'cancelled' + run: | + set -euo pipefail + for n in $(gh issue list -R "$GITHUB_REPOSITORY" --state open --search 'in:title "custom-nightly failed"' --json number -q '.[].number'); do + gh issue close "$n" -R "$GITHUB_REPOSITORY" --comment "Fixed: published ${RELEASE_TAG} in ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}." + done + + report_failure: + name: Report failure + needs: [prepare, build, build_linux, build_mac, build_android, publish] + # GitHub cancels a job it never acquired (no runner capacity), which failure() misses. + if: failure() || contains(needs.*.result, 'cancelled') + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + issues: write + env: + GH_TOKEN: ${{ github.token }} + DETAIL: ${{ needs.prepare.outputs.failure }} + UPSTREAM_TAG: ${{ needs.prepare.outputs.upstream_tag }} + RESULTS: "prepare=${{ needs.prepare.result }} windows=${{ needs.build.result }} linux=${{ needs.build_linux.result }} mac=${{ needs.build_mac.result }} android=${{ needs.build_android.result }} publish=${{ needs.publish.result }}" + steps: + - name: Open or update the failure issue + run: | + set -euo pipefail + run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + body="$(printf '%s\n\n%s\n\n%s\n\n%s\n' \ + "Custom nightly for upstream \`${UPSTREAM_TAG:-unknown}\` failed: ${run_url}" \ + "Jobs: ${RESULTS}" \ + "${DETAIL:-See the run log for details.}" \ + "If prepare failed, nothing was published and \`custom\` was not pushed. If only some builds failed, the others were published and the next scheduled run retries the missing platforms. See CUSTOM.md for how to resolve.")" + n="$(gh issue list -R "$GITHUB_REPOSITORY" --state open --search 'in:title "custom-nightly failed"' --json number -q '.[0].number')" + if [[ -n "$n" ]]; then + gh issue comment "$n" -R "$GITHUB_REPOSITORY" --body "$body" + else + gh issue create -R "$GITHUB_REPOSITORY" --title "custom-nightly failed" --body "$body" + fi diff --git a/.github/workflows/deploy-relay.yml b/.github/workflows/deploy-relay.yml index da779c2783d4..7d40d1381ba7 100644 --- a/.github/workflows/deploy-relay.yml +++ b/.github/workflows/deploy-relay.yml @@ -58,6 +58,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 with: diff --git a/.github/workflows/desktop-macos-preview.yml b/.github/workflows/desktop-macos-preview.yml index 2c54052ea66d..1e709758d47a 100644 --- a/.github/workflows/desktop-macos-preview.yml +++ b/.github/workflows/desktop-macos-preview.yml @@ -56,6 +56,11 @@ jobs: cache: true run-install: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Install bundle dependencies run: vp install --filter=t3... --filter=@t3tools/web... --filter=@t3tools/desktop... --filter=@t3tools/scripts... diff --git a/.github/workflows/mobile-dev-client.yml b/.github/workflows/mobile-dev-client.yml index b3e11c1ed6b6..30ca7abcb6fc 100644 --- a/.github/workflows/mobile-dev-client.yml +++ b/.github/workflows/mobile-dev-client.yml @@ -158,6 +158,11 @@ jobs: sudo apt-get update -qq && sudo apt-get install -y -qq ccache ccache --zero-stats + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -273,6 +278,11 @@ jobs: exit 1 fi + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: diff --git a/.github/workflows/mobile-eas-preview.yml b/.github/workflows/mobile-eas-preview.yml index 53061f25e9c4..724eb0c84f0c 100644 --- a/.github/workflows/mobile-eas-preview.yml +++ b/.github/workflows/mobile-eas-preview.yml @@ -52,6 +52,11 @@ jobs: if: steps.expo-token.outputs.present == 'true' uses: ./.github/actions/drop-checkout-credentials + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ if: steps.expo-token.outputs.present == 'true' uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 @@ -174,6 +179,11 @@ jobs: if: steps.expo-token.outputs.present == 'true' uses: ./.github/actions/drop-checkout-credentials + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ if: steps.expo-token.outputs.present == 'true' uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 @@ -290,6 +300,11 @@ jobs: - name: Drop checkout credentials uses: ./.github/actions/drop-checkout-credentials + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Build if: steps.record.outputs.built != 'true' uses: ./.github/actions/eas-local-build @@ -374,6 +389,11 @@ jobs: - name: Drop checkout credentials uses: ./.github/actions/drop-checkout-credentials + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Build if: steps.record.outputs.built != 'true' uses: ./.github/actions/eas-local-build diff --git a/.github/workflows/mobile-eas-production.yml b/.github/workflows/mobile-eas-production.yml index fe4d7456acdf..a20dd3f35033 100644 --- a/.github/workflows/mobile-eas-production.yml +++ b/.github/workflows/mobile-eas-production.yml @@ -139,6 +139,11 @@ jobs: # `git clone --depth 1 file://`, which fails (exit 128) # when the partial clone can't serve the unfetched blobs. + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ if: steps.expo-token.outputs.present == 'true' uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 @@ -495,6 +500,11 @@ jobs: echo ":white_check_mark: android: \`$BUILD_TAG\` was built by an earlier run" >> "$GITHUB_STEP_SUMMARY" fi + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Build if: steps.record.outputs.built != 'true' uses: ./.github/actions/eas-local-build @@ -586,6 +596,11 @@ jobs: echo ":white_check_mark: ios: \`$BUILD_TAG\` was built by an earlier run" >> "$GITHUB_STEP_SUMMARY" fi + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Build if: steps.record.outputs.built != 'true' uses: ./.github/actions/eas-local-build diff --git a/.github/workflows/mobile-fingerprint-check.yml b/.github/workflows/mobile-fingerprint-check.yml index 11d2ee60e122..5261d7f14e0d 100644 --- a/.github/workflows/mobile-fingerprint-check.yml +++ b/.github/workflows/mobile-fingerprint-check.yml @@ -59,6 +59,11 @@ jobs: echo "No native fingerprint inputs changed; clearing any stale native change label." >> "$GITHUB_STEP_SUMMARY" fi + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ if: steps.changes.outputs.relevant == 'true' uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 diff --git a/.github/workflows/mobile-showcase-screenshots.yml b/.github/workflows/mobile-showcase-screenshots.yml index 16a70a58aac0..a48dd6bb35dd 100644 --- a/.github/workflows/mobile-showcase-screenshots.yml +++ b/.github/workflows/mobile-showcase-screenshots.yml @@ -58,6 +58,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 with: @@ -123,6 +128,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 with: diff --git a/.github/workflows/relay-preview-cleanup.yml b/.github/workflows/relay-preview-cleanup.yml index 483e3e0b01b7..6bc0e308d463 100644 --- a/.github/workflows/relay-preview-cleanup.yml +++ b/.github/workflows/relay-preview-cleanup.yml @@ -66,6 +66,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 with: @@ -178,6 +183,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ if: steps.eligible.outputs.eligible == 'yes' uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 diff --git a/.github/workflows/relay-preview.yml b/.github/workflows/relay-preview.yml index daec31908775..f9a9b43be2b3 100644 --- a/.github/workflows/relay-preview.yml +++ b/.github/workflows/relay-preview.yml @@ -61,6 +61,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 with: diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml index 2d3a38168c79..51e1d8abb493 100644 --- a/.github/workflows/release-desktop.yml +++ b/.github/workflows/release-desktop.yml @@ -176,6 +176,11 @@ jobs: name: release-dependency-verification path: ${{ runner.temp }}/pnpm-metadata + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c1bd673dab60..418bbe5ce006 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -134,6 +134,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -247,6 +252,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -279,6 +289,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -319,6 +334,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -378,6 +398,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -431,6 +456,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -550,6 +580,11 @@ jobs: name: release-dependency-verification path: ${{ runner.temp }}/pnpm-metadata + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -828,6 +863,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -1118,6 +1158,11 @@ jobs: /pnpm-workspace.yaml sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Node.js uses: ./.github/actions/setup-ci-deps with: @@ -1206,6 +1251,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -1228,6 +1278,11 @@ jobs: - name: Align package versions to release version run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}" + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Refresh release lockfile run: vp install --lockfile-only --ignore-scripts @@ -1307,6 +1362,11 @@ jobs: /pnpm-workspace.yaml sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: ./.github/actions/setup-ci-deps with: @@ -1377,6 +1437,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -1443,6 +1508,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: ./.github/actions/setup-ci-deps with: @@ -1501,6 +1571,11 @@ jobs: echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT" echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT" + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: @@ -1516,6 +1591,11 @@ jobs: if: steps.update_versions.outputs.changed == 'true' run: vp fmt apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Refresh lockfile if: steps.update_versions.outputs.changed == 'true' run: vp install --lockfile-only --ignore-scripts @@ -1572,6 +1652,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup dependencies uses: ./.github/actions/setup-ci-deps with: diff --git a/.github/workflows/web-preview.yml b/.github/workflows/web-preview.yml index 69db6b6025e8..984e220c3e85 100644 --- a/.github/workflows/web-preview.yml +++ b/.github/workflows/web-preview.yml @@ -54,6 +54,11 @@ jobs: !/.repos/ sparse-checkout-cone-mode: false + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Setup Vite+ uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 with: diff --git a/.github/workflows/windows-tests.yml b/.github/workflows/windows-tests.yml index 9a8e69d69cc2..e91e73777a81 100644 --- a/.github/workflows/windows-tests.yml +++ b/.github/workflows/windows-tests.yml @@ -57,6 +57,11 @@ jobs: path: ${{ steps.package_cache_path.outputs.path }} key: windows-tests-packages-v1-${{ hashFiles('pnpm-lock.yaml') }} + - name: Use the BoopFace read key + uses: ./.github/actions/boopface-key + with: + key: ${{ secrets.BOOPFACE_READ_KEY }} + - name: Install run: vp install diff --git a/.gitignore b/.gitignore index 1637f475fbbd..e28dfb72f49a 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,6 @@ node_modules/ .pnpm-store/ /packages/ssh/.ssh-launcher-test-*/ + +# Rendered webhook faces (runtime cache). +.webhook-avatars/ diff --git a/CUSTOM.md b/CUSTOM.md new file mode 100644 index 000000000000..9be4799a89cd --- /dev/null +++ b/CUSTOM.md @@ -0,0 +1,154 @@ +# CarsonJF/t3code custom build + +This fork ships **latest upstream nightly + the commits on `custom`** as Windows x64 and +macOS desktop builds that auto-update from this fork's releases, an Android APK, and a +Linux x64 CLI archive (the server runtime, and the WSL backend in the Windows installer). +Every build's updater points at this fork, so the clients' "Update everything" action moves +servers to the custom release too. + +## Branches + +- `main`: pure mirror of `pingdotgg/t3code` main. Never commit to it; the pipeline force-updates it. +- `custom` (default branch): the upstream nightly tag plus our commits. Our commits are + everything on `custom` that is not on upstream main. CI files live only in new files + (`.github/workflows/custom-nightly.yml`, this file), so rebases never conflict on them. + +## How the pipeline works + +`.github/workflows/custom-nightly.yml` runs every 3 hours (and on demand): + +1. Finds the newest published upstream `v*-nightly.*` release. If this fork's release + `-custom` already has every platform (`nightly.yml`, `nightly-mac.yml`, an + `.apk`, and the `t3-*-linux-x64.tar.gz` + `SHA256SUMS` pair), it stops. If it has only + some, it rebuilds just the missing platforms at that release's commit and attaches them + (no rebase). A release without the custom Linux CLI is rebuilt in full instead, so an + old tag cannot publish an updater that still points at upstream. +2. Rebases our commits onto that tag (`git rebase --onto `), runs + `vp run check:changed ` (format, lint, knip, affected typecheck, tests beside our + changes), then pushes `custom` with `--force-with-lease` and mirrors `main`. +3. Builds four platforms in parallel, independently, all with the upstream version number + and the T3 Connect repo variables (`T3CODE_CLERK_*`, `T3CODE_RELAY_URL`): + - Windows: NSIS installer on `windows-latest`, update feed pointed at this fork + (`T3CODE_DESKTOP_UPDATE_REPOSITORY`), `dev` telemetry, and this run's Linux CLI + archive as the WSL runtime. + - macOS: dmg + zip for arm64 and x64 on `macos-26`, same feed override, signed with the + fork's self-signed certificate (secret `CUSTOM_MAC_SIGNING_P12`) so updates verify. + Not notarized. + - Android: `APP_VARIANT=preview` release APK (arm64) via `expo prebuild` + Gradle, OTA + updates off, re-signed with the fork's keystore (secret `CUSTOM_ANDROID_KEYSTORE`). + - Linux x64: the `t3` single-executable plus web client and resource monitor, packaged + as `t3--linux-x64.tar.gz` with a `SHA256SUMS` asset. This is the server + runtime and the WSL backend, so it carries the custom server commits; its updater is + baked to read this fork's releases. +4. Publishes a prerelease with whatever built. A platform that failed is retried by the next + scheduled run until a newer upstream nightly replaces the release. The release's CLI + archive and `SHA256SUMS` are what `t3 update` and the clients' "Update everything" action + download, and the baked release repository is this fork. + +Any failure opens (or comments on) one issue titled `custom-nightly failed`; a later run +with no failed build closes it. A conflicted rebase is aborted, so `custom` is never pushed +half-rebased. Pushes use the `CUSTOM_NIGHTLY_DEPLOY_KEY` secret (a write deploy key), because +`GITHUB_TOKEN` cannot push commits that touch workflow files. + +The job also re-disables every other workflow on the fork, so inherited upstream +workflows never run here. + +## Pause / resume + + gh workflow disable custom-nightly.yml -R CarsonJF/t3code + gh workflow enable custom-nightly.yml -R CarsonJF/t3code + +Run now: `gh workflow run custom-nightly.yml -R CarsonJF/t3code` (add `-f force=true` to +rebuild an existing release, `-f upstream_tag=v...` to pick a tag). Without `gh` auth, push a +throwaway tag instead — it checks out `custom` and runs the same pipeline: +`git push -f origin HEAD:publish-custom-nightly` (or `git tag -f publish-custom-nightly && +git push -f origin publish-custom-nightly`). If the macOS job fails with "not acquired by +Runner", arm64 runners are out of capacity: rerun with `-f mac_runner=macos-15-intel`. + +## Resolving a rebase conflict + + git fetch upstream --tags && git fetch origin + git switch custom && git reset --hard origin/custom + git rebase --onto $(git merge-base HEAD upstream/main) + # fix conflicts, git add, git rebase --continue + git push --force-with-lease origin custom + gh workflow run custom-nightly.yml -R CarsonJF/t3code + +### Migration ids + +Fork migrations keep the id they shipped with, forever. Installed databases record each +migration as `, `, and the migrator runs only ids above the highest recorded one, +so renumbering a migration that already shipped breaks every existing database. That is how +the `.4941` custom build failed: it moved `ScheduledTaskCreatedByTot` from 99 to 101, and +every database that had recorded 99 refused to start. + +- 99 is `ScheduledTaskCreatedByTot`. Upstream's migrations from its 99 on sit one id higher + here (upstream 099 is our 100, and so on). When a rebase brings a new upstream migration, + rename its file and manifest entry to upstream id + 1, append it after ours, and update any + test that names its id. +- Every migration from 99 on must be idempotent (`IF NOT EXISTS`, a column check, or a + drop and rebuild). Startup and the update preflight rewind a history recorded in another + order (stock upstream, or the `.4941` custom build) and replay it in ours; see + `withoutReorderedMigrations` in `apps/server/src/persistence/Migrations.ts`. +- A new fork migration takes the next id after the last one in the manifest, and upstream + migrations that land after it shift one id further. Update the offset above when that + happens, and keep the new migration idempotent. +- `Migrations.test.ts` holds the regression cases for these histories; keep them passing. + +## Installing + +### Windows + +Download `T3-Code--x64.exe` from the newest release and run it. It installs over +the stock T3 Code (Nightly) (same app id, product name and data directory), keeping all +data and settings. SmartScreen warns because it is unsigned: More info, then Run anyway. +From then on the app updates from this fork's releases. Reinstalling a stock installer +switches updates back to upstream. + +### macOS + +Download `T3-Code--arm64.dmg` (Apple silicon) or `-x64.dmg` (Intel), drag the app +to Applications, replacing a stock T3 Code (Nightly) if present. Data and settings carry +over (same app id and data directory). Once: open it, dismiss the "cannot verify" dialog, +then System Settings > Privacy & Security > Open Anyway (or run +`xattr -dr com.apple.quarantine "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/Applications/T3 Code (Nightly).app"`). macOS may ask once +for keychain access to "T3 Code (Nightly) Safe Storage" and re-ask for camera, microphone, +screen recording or folder permissions, because the signer changed. After that it +auto-updates from this fork like Windows; updates only work from a build of this fork, not +from a stock install. + +### Linux (server) + +Download `t3--linux-x64.tar.gz` from the newest release and install it as the +pinned runtime, then let it own the background service: + +```bash +V= +mkdir -p "$HOME/.t3/runtime/versions/$V" +tar -xzf "t3-$V-linux-x64.tar.gz" -C "$HOME/.t3/runtime/versions/$V" --strip-components=1 +printf '%s\n' "$V" > "$HOME/.t3/runtime/versions/$V/.install-complete" +ln -sfn "$HOME/.t3/runtime/versions/$V/t3" "$HOME/.local/bin/t3" +"$HOME/.local/bin/t3" service install +``` + +From then on the server follows this fork's nightly releases. `t3 update` from a terminal, +or the desktop/web "Update everything" action, moves every environment to the newest +release; environments already on it are skipped. A server restored from a stock install +first needs the one-time archive install above. + +### Android + +Download `T3-Code-Custom--android-arm64.apk` on the phone and open it; allow +"Install unknown apps" for the browser or file manager when asked. It installs as +**T3 Code Preview** (`com.t3tools.t3code.preview`) next to the store app, so pair it again +and sign in to T3 Connect again. Scan pairing QR codes with the app's own scanner (the +system camera opens the store app). Updates are manual: install the newer APK over the old +one; data is kept. No push notifications (no Firebase config). + +## Signing keys + +The macOS certificate and the Android keystore exist only in the repo secrets +(`CUSTOM_MAC_SIGNING_P12`/`_PASSWORD`, `CUSTOM_ANDROID_KEYSTORE`/`_PASSWORD`) and the +owner's offline backup. Keep the backup: with a new key, the installed Mac app stops +accepting updates and the APK no longer installs over the old one, so each needs a one-time +manual reinstall (Android: uninstall first, losing app data). diff --git a/apps/discord-bot/.env.example b/apps/discord-bot/.env.example new file mode 100644 index 000000000000..bba2d2f15eb4 --- /dev/null +++ b/apps/discord-bot/.env.example @@ -0,0 +1,33 @@ +# Discord bot token from the application's Bot page. +DISCORD_TOKEN= + +# Comma-separated Discord user ids. DMs and channel messages from anyone else +# are ignored silently. +DISCORD_ALLOWED_USER_IDS= + +# One machine. The T3 Code environment's MCP endpoint, for example +# http://127.0.0.1:3773/mcp, and a bearer token minted once with +# `npm run mint-token` for that machine. +# Set this pair, or T3_ENVIRONMENTS below, never both. +T3_MCP_URL= +T3_MCP_TOKEN= + +# Several machines, as a JSON array. `label` is the machine name people see in +# /tot list, /tot use and channel names; it needs its own token from that +# machine. Example: +# T3_ENVIRONMENTS=[{"label":"laptop","mcpUrl":"http://127.0.0.1:3773/mcp","token":"..."},{"label":"office","mcpUrl":"https://office.tailnet.ts.net/mcp","token":"..."}] +T3_ENVIRONMENTS= + +# Optional: a server id. With it, the bot gives every Tot a text channel named +# tot- (tot-