Skip to content

Commit bd62aac

Browse files
ci(desktop): read preview public config from the built commit
Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 53a01e1 commit bd62aac

2 files changed

Lines changed: 20 additions & 22 deletions

File tree

‎.github/workflows/desktop-macos-preview-publish.yml‎

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,12 @@ jobs:
155155
;;
156156
esac
157157
158-
- name: Checkout main
159-
if: steps.gate.outputs.eligible == 'true'
160-
uses: actions/checkout@v6
161-
with:
162-
ref: ${{ github.event.repository.default_branch }}
163-
sparse-checkout: .env.example
164-
sparse-checkout-cone-mode: false
165-
166-
# Same version formula as the build workflow: the base version from the
167-
# built commit's desktop manifest plus the build run's number, so the
168-
# packaged app matches the version baked into the bundle even when the
169-
# PR and main disagree on the base version. The manifest is read through
170-
# the API as data and the version is validated before it reaches a file
171-
# name. The T3 Connect identifiers come from main's .env.example, the
172-
# same public values the bundle was built with.
158+
# Same inputs as the build workflow, read from the built commit through
159+
# the contents API as data: the desktop manifest's base version plus the
160+
# build run's number reproduces the version baked into the bundle, and
161+
# .env.example holds the public T3 Connect identifiers the bundle was
162+
# compiled with, which the signed app's passkey entitlement must match.
163+
# Both are validated before they reach a file name or an entitlement.
173164
- id: version
174165
name: Resolve preview version and public configuration
175166
if: steps.gate.outputs.eligible == 'true'
@@ -181,19 +172,24 @@ jobs:
181172
BUILD_RUN_NUMBER: ${{ github.event.workflow_run.run_number }}
182173
run: |
183174
set -euo pipefail
184-
base_version="$(gh api "repos/${GITHUB_REPOSITORY}/contents/apps/desktop/package.json?ref=${HEAD_SHA}" \
185-
--jq '.content' | base64 --decode | node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).version")"
186-
if [[ ! "$base_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
175+
head_file() {
176+
gh api "repos/${GITHUB_REPOSITORY}/contents/$1?ref=${HEAD_SHA}" --jq '.content' | base64 --decode
177+
}
178+
179+
base_version="$(head_file apps/desktop/package.json | node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).version")"
180+
if [[ ! "$base_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
187181
echo "Unexpected desktop version '$base_version' at $HEAD_SHA." >&2
188182
exit 1
189183
fi
190184
echo "version=${base_version}-pr.${PR_NUMBER}.${BUILD_RUN_NUMBER}" >> "$GITHUB_OUTPUT"
185+
186+
head_file .env.example > "$RUNNER_TEMP/head.env.example"
191187
for key in clerk_publishable_key:T3CODE_CLERK_PUBLISHABLE_KEY clerk_jwt_template:T3CODE_CLERK_JWT_TEMPLATE clerk_cli_oauth_client_id:T3CODE_CLERK_CLI_OAUTH_CLIENT_ID relay_url:T3CODE_RELAY_URL; do
192188
output="${key%%:*}"
193189
name="${key##*:}"
194-
value="$(sed -n "s/^${name}=//p" .env.example | head -n 1)"
195-
if [[ -z "$value" ]]; then
196-
echo "$name is missing from .env.example." >&2
190+
value="$(sed -n "s/^${name}=//p" "$RUNNER_TEMP/head.env.example" | head -n 1)"
191+
if [[ ! "$value" =~ ^[A-Za-z0-9._:/-]+$ ]]; then
192+
echo "$name is missing or malformed in .env.example at $HEAD_SHA." >&2
197193
exit 1
198194
fi
199195
echo "${output}=${value}" >> "$GITHUB_OUTPUT"

‎docs/operations/release.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ Developer ID certificate never shares a job with PR code:
6363
collaborator or listed in `.github/VOUCHED.td` (read from the default branch, so a PR cannot vouch
6464
for itself). It then packages and signs the bundle through `release-desktop.yml` checked out at
6565
`main`, so packaging, native helpers, and the Electron/desktop dependencies come from `main`, not
66-
the PR. A PR that changes those must use the `channel=preview` release train above instead.
66+
the PR. Only the version and the public T3 Connect identifiers in `.env.example` are read from the
67+
PR commit, as data, so the signed app's passkey entitlement matches the bundle. A PR that changes
68+
packaging must use the `channel=preview` release train above instead.
6769

6870
The signed bundle is only ever copied into the app, never executed, on the signing runner. The
6971
`pull_request_target` cleanup job in the publish workflow removes the download when the PR closes or

0 commit comments

Comments
 (0)