Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

ci(macos): notarize with an API key and gate signing on approval

RoversXbd6888545069
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 0aff4d2b..0e935155 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -264,6 +264,9 @@ jobs:
include: ${{ fromJSON(needs.prepare.outputs.macos_matrix) }}
runs-on: macos-latest
timeout-minutes: 90
+ # The signing certificate and the notarization key are this
+ # environment's secrets: a run only reaches them once it is approved.
+ environment: release
env:
MACOSX_DEPLOYMENT_TARGET: '14.0'
@@ -336,6 +339,9 @@ jobs:
MACOS_CERT: ${{ secrets.MACOS_CERT }}
MACOS_CERT_PW: ${{ secrets.MACOS_CERT_PW }}
MACOS_TEAM_ID: ${{ secrets.MACOS_TEAM_ID }}
+ MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
+ MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
+ MACOS_NOTARY_ISSUER: ${{ secrets.MACOS_NOTARY_ISSUER }}
CARGO_PROFILE: dist
run: bash ci/deploy.sh
diff --git a/ci/deploy.sh b/ci/deploy.sh
index af5940f9..52b96852 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -172,8 +172,6 @@ case $OSTYPE in
fi
elif [ -n "$MACOS_TEAM_ID" ] ; then
MACOS_PW=$(echo $MACOS_CERT_PW | base64 --decode)
- echo "pw sha"
- echo $MACOS_PW | shasum
# Remove pesky additional quotes from default-keychain output
def_keychain=$(eval echo $(security default-keychain -d user))
@@ -188,8 +186,6 @@ case $OSTYPE in
security unlock-keychain -p "$MACOS_PW" build.keychain
echo "Import .p12 data"
echo $MACOS_CERT | base64 --decode > /tmp/certificate.p12
- echo "decoded sha"
- shasum /tmp/certificate.p12
security import /tmp/certificate.p12 -k build.keychain -P "$MACOS_PW" -T /usr/bin/codesign
rm /tmp/certificate.p12
echo "Grant apple tools access to build.keychain"
diff --git a/ci/macos-notarize-local.sh b/ci/macos-notarize-local.sh
index e59dde4e..7d5e74af 100755
--- a/ci/macos-notarize-local.sh
+++ b/ci/macos-notarize-local.sh
@@ -5,10 +5,26 @@ set -euo pipefail
APP_PATH=${1:?usage: macos-notarize-local.sh path/to/ThinkTerm.app [keychain-profile]}
PROFILE=${2:-${MACOS_NOTARY_PROFILE:-thinkterm}}
+if [[ ! -d "$APP_PATH" ]]; then
+ echo "App bundle not found: ${APP_PATH}" >&2
+ exit 1
+fi
+
+WORK_DIR=$(mktemp -d)
+trap 'rm -rf "$WORK_DIR"' EXIT
+
# Locally the credentials live in a keychain profile created once with
# `notarytool store-credentials`. A CI runner has no such keychain, so prefer
-# the credentials passed in the environment whenever all three are present.
-if [[ -n "${MACOS_APPLEID:-}" && -n "${MACOS_APP_PW:-}" && -n "${MACOS_TEAM_ID:-}" ]]; then
+# credentials passed in the environment: an App Store Connect API key (the
+# .p8 file base64-encoded, its key ID and the issuer ID), which is tied to no
+# person's Apple ID and can be revoked on its own; else an Apple ID with an
+# app-specific password.
+if [[ -n "${MACOS_NOTARY_KEY:-}" && -n "${MACOS_NOTARY_KEY_ID:-}" && -n "${MACOS_NOTARY_ISSUER:-}" ]]; then
+ KEY_FILE="$WORK_DIR/AuthKey_${MACOS_NOTARY_KEY_ID}.p8"
+ (umask 077 && printf '%s' "$MACOS_NOTARY_KEY" | base64 --decode >"$KEY_FILE")
+ NOTARY_AUTH=(--key "$KEY_FILE" --key-id "$MACOS_NOTARY_KEY_ID" --issuer "$MACOS_NOTARY_ISSUER")
+ echo "==> Using an App Store Connect API key from the environment"
+elif [[ -n "${MACOS_APPLEID:-}" && -n "${MACOS_APP_PW:-}" && -n "${MACOS_TEAM_ID:-}" ]]; then
NOTARY_AUTH=(--apple-id "$MACOS_APPLEID" --password "$MACOS_APP_PW" --team-id "$MACOS_TEAM_ID")
echo "==> Using notarization credentials from the environment"
else
@@ -16,16 +32,9 @@ else
echo "==> Using notarization credentials from keychain profile '$PROFILE'"
fi
-if [[ ! -d "$APP_PATH" ]]; then
- echo "App bundle not found: ${APP_PATH}" >&2
- exit 1
-fi
-
# Notarization only accepts a container, never a bare .app, and it has to be
# built with ditto: plain `zip` drops the symlinks and extended attributes that
# codesign relies on, which Apple rejects as a damaged bundle.
-WORK_DIR=$(mktemp -d)
-trap 'rm -rf "$WORK_DIR"' EXIT
SUBMISSION_ZIP="$WORK_DIR/submission.zip"
RESULT_PLIST="$WORK_DIR/result.plist"