From 8fe60c5f6d2b04bae5ca364ce91700e1715a3ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 3 Dec 2026 09:29:20 +0100 Subject: [PATCH 1/3] ci(release): sign Android helper releases from the protected release environment Nightlies run release.yml from main and check out the 0.22 SHA. Once 0.22 drops the committed helper key (#5341), its build script needs the release keystore, and with AGENT_DEVICE_ANDROID_HELPER_RELEASE=1 it fails instead of using a throwaway key. Publishing jobs now run in the release environment, export the keystore, and set the marker; PR dry runs get neither. --- .../setup-android-helper-signing/action.yml | 25 +++++++++++++++++++ .../release-android-snapshot-helper.yml | 10 ++++++++ .github/workflows/release.yml | 12 +++++++++ test/ci/release-workflow.test.ts | 14 ++++++++--- 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 .github/actions/setup-android-helper-signing/action.yml diff --git a/.github/actions/setup-android-helper-signing/action.yml b/.github/actions/setup-android-helper-signing/action.yml new file mode 100644 index 00000000000..f1d14363650 --- /dev/null +++ b/.github/actions/setup-android-helper-signing/action.yml @@ -0,0 +1,25 @@ +name: Setup Android helper signing +description: Exports the release keystore that scripts/build-android-helper.sh signs with. +inputs: + keystore-base64: + description: Base64 of the release keystore. + required: false + keystore-password: + description: Password of the release keystore and its key. + required: false +runs: + using: composite + steps: + - shell: bash + env: + KEYSTORE_BASE64: ${{ inputs.keystore-base64 }} + KEYSTORE_PASSWORD: ${{ inputs.keystore-password }} + run: | + set -euo pipefail + if [ -z "$KEYSTORE_BASE64" ] || [ -z "$KEYSTORE_PASSWORD" ]; then + echo "::error::Release builds need the ANDROID_HELPER_KEYSTORE_BASE64 and ANDROID_HELPER_KEYSTORE_PASSWORD secrets." + exit 1 + fi + printf '%s' "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/android-helper.keystore" + echo "AGENT_DEVICE_ANDROID_KEYSTORE=$RUNNER_TEMP/android-helper.keystore" >> "$GITHUB_ENV" + echo "AGENT_DEVICE_ANDROID_KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD" >> "$GITHUB_ENV" diff --git a/.github/workflows/release-android-snapshot-helper.yml b/.github/workflows/release-android-snapshot-helper.yml index b87afd6f2f7..7c9cce0d461 100644 --- a/.github/workflows/release-android-snapshot-helper.yml +++ b/.github/workflows/release-android-snapshot-helper.yml @@ -27,6 +27,10 @@ jobs: name: Publish Android Snapshot Helper runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 + # The helper keystore secrets live only in the protected `release` environment. + environment: release + env: + AGENT_DEVICE_ANDROID_HELPER_RELEASE: '1' steps: - name: Checkout uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2 @@ -64,6 +68,12 @@ jobs: - name: Setup Android SDK uses: ./.github/actions/setup-android-sdk + - name: Setup Android helper signing + uses: ./.github/actions/setup-android-helper-signing + with: + keystore-base64: ${{ secrets.ANDROID_HELPER_KEYSTORE_BASE64 }} + keystore-password: ${{ secrets.ANDROID_HELPER_KEYSTORE_PASSWORD }} + - name: Check Java toolchain run: | javac --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d894944efd3..fab28abe40d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,8 +85,13 @@ jobs: permissions: contents: read cache-mode: none + # The helper keystore secrets live only in the protected `release` environment, so PR dry + # runs never receive them and sign with a throwaway key. + environment: ${{ needs.plan.outputs.mode != 'dry-run' && 'release' || '' }} env: VERSION: ${{ needs.plan.outputs.version }} + # scripts/build-android-helper.sh fails instead of using a throwaway key when this is set. + AGENT_DEVICE_ANDROID_HELPER_RELEASE: ${{ needs.plan.outputs.mode != 'dry-run' && '1' || '' }} steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -113,6 +118,13 @@ jobs: - name: Setup Android SDK uses: ./.github/actions/setup-android-sdk + - name: Setup Android helper signing + if: needs.plan.outputs.mode != 'dry-run' + uses: ./.github/actions/setup-android-helper-signing + with: + keystore-base64: ${{ secrets.ANDROID_HELPER_KEYSTORE_BASE64 }} + keystore-password: ${{ secrets.ANDROID_HELPER_KEYSTORE_PASSWORD }} + - name: Stamp release version run: node .release-tools/scripts/release-version.mjs stamp "$VERSION" diff --git a/test/ci/release-workflow.test.ts b/test/ci/release-workflow.test.ts index f67b9f43f99..10bed303ec2 100644 --- a/test/ci/release-workflow.test.ts +++ b/test/ci/release-workflow.test.ts @@ -45,14 +45,20 @@ const secretsOf = (job: Job) => test('the publisher authenticates through OIDC alone', () => { expect(source).not.toMatch(/NPM_TOKEN|NODE_AUTH_TOKEN/); - // No secret reaches the jobs that build or publish the packages. The one secret in the file - // is the site's deploy hook, which only the redeploy job after a stable release reads. + // No secret reaches the publisher. The build reads only the Android helper keystore, and only + // in the protected `release` environment that PR dry runs never enter. The site's deploy hook + // is read only by the redeploy job after a stable release. expect(secretsOf(workflow.jobs.publish ?? {})).toEqual([]); - expect(secretsOf(workflow.jobs.build ?? {})).toEqual([]); + expect(workflow.jobs.build?.environment).toBe( + "${{ needs.plan.outputs.mode != 'dry-run' && 'release' || '' }}", + ); const withSecrets = Object.entries(workflow.jobs) .map(([name, job]) => [name, secretsOf(job)] as const) .filter(([, names]) => names.length > 0); - expect(withSecrets).toEqual([['redeploy-site', ['VERCEL_SITE_DEPLOY_HOOK']]]); + expect(withSecrets).toEqual([ + ['build', ['ANDROID_HELPER_KEYSTORE_BASE64', 'ANDROID_HELPER_KEYSTORE_PASSWORD']], + ['redeploy-site', ['VERCEL_SITE_DEPLOY_HOOK']], + ]); const setupNode = workflow.jobs.publish?.steps?.find((step) => step.uses?.startsWith('actions/setup-node@'), ); From f46b585aa5ee0d05a1c8bd02f774553df78be9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 3 Dec 2026 10:14:39 +0100 Subject: [PATCH 2/3] fix(ci): pass helper keystore password only to signing steps --- .github/actions/setup-android-helper-signing/action.yml | 3 +-- .github/workflows/release-android-snapshot-helper.yml | 1 + .github/workflows/release.yml | 4 +++- test/ci/release-workflow.test.ts | 7 +++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-android-helper-signing/action.yml b/.github/actions/setup-android-helper-signing/action.yml index f1d14363650..0c8b9797a7a 100644 --- a/.github/actions/setup-android-helper-signing/action.yml +++ b/.github/actions/setup-android-helper-signing/action.yml @@ -1,5 +1,5 @@ name: Setup Android helper signing -description: Exports the release keystore that scripts/build-android-helper.sh signs with. +description: Writes the release keystore and exports its path. The caller passes the password to its build step. inputs: keystore-base64: description: Base64 of the release keystore. @@ -22,4 +22,3 @@ runs: fi printf '%s' "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/android-helper.keystore" echo "AGENT_DEVICE_ANDROID_KEYSTORE=$RUNNER_TEMP/android-helper.keystore" >> "$GITHUB_ENV" - echo "AGENT_DEVICE_ANDROID_KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD" >> "$GITHUB_ENV" diff --git a/.github/workflows/release-android-snapshot-helper.yml b/.github/workflows/release-android-snapshot-helper.yml index 7c9cce0d461..93ada4535b8 100644 --- a/.github/workflows/release-android-snapshot-helper.yml +++ b/.github/workflows/release-android-snapshot-helper.yml @@ -86,6 +86,7 @@ jobs: RELEASE_VERSION: ${{ steps.meta.outputs.version }} RELEASE_TAG: ${{ steps.meta.outputs.tag }} AGENT_DEVICE_ANDROID_HELPER: snapshot + AGENT_DEVICE_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_HELPER_KEYSTORE_PASSWORD }} run: | set -euo pipefail mkdir -p "${RELEASE_ASSET_DIR}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fab28abe40d..99f99e7bfc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -129,6 +129,8 @@ jobs: run: node .release-tools/scripts/release-version.mjs stamp "$VERSION" - name: Build and verify every public package + env: + AGENT_DEVICE_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_HELPER_KEYSTORE_PASSWORD }} run: pnpm release:prepare - name: Upload packages @@ -293,7 +295,7 @@ jobs: # agent-device.dev serves /.well-known/mcp.json with the npm `latest` version read when the # site builds. A tag push builds nothing on Vercel, so ask for a production build of main once # npm serves the new version. The VERCEL_SITE_DEPLOY_HOOK secret holds the Vercel deploy hook - # of the agent-device-website project for main; it is the only secret this workflow reads. + # of the agent-device-website project for main; it is the only secret the post-publish jobs read. redeploy-site: name: Redeploy agent-device.dev needs: [plan, publish] diff --git a/test/ci/release-workflow.test.ts b/test/ci/release-workflow.test.ts index 10bed303ec2..d9f6a107898 100644 --- a/test/ci/release-workflow.test.ts +++ b/test/ci/release-workflow.test.ts @@ -40,8 +40,11 @@ test('only the npm publisher and the MCP Registry call can mint an id-token', () }); /** The secret names a job references, wherever in the job they appear. */ -const secretsOf = (job: Job) => - [...JSON.stringify(job).matchAll(/secrets\.([A-Za-z0-9_]+)/g)].map(([, name]) => name); +const secretsOf = (job: Job) => [ + ...new Set( + [...JSON.stringify(job).matchAll(/secrets\.([A-Za-z0-9_]+)/g)].map(([, name]) => name), + ), +]; test('the publisher authenticates through OIDC alone', () => { expect(source).not.toMatch(/NPM_TOKEN|NODE_AUTH_TOKEN/); From 9f46ad65b8ab955c409d2804a1a7ebab08c274aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 3 Dec 2026 14:48:09 +0100 Subject: [PATCH 3/3] fix(ci): load helper signing from the workflow commit and build only github.ref --- .github/workflows/release-android-snapshot-helper.yml | 9 +++------ .github/workflows/release.yml | 7 +++++-- test/ci/release-workflow.test.ts | 7 +++++++ test/repo-guards/release-assets.test.ts | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-android-snapshot-helper.yml b/.github/workflows/release-android-snapshot-helper.yml index 93ada4535b8..c6d1437579c 100644 --- a/.github/workflows/release-android-snapshot-helper.yml +++ b/.github/workflows/release-android-snapshot-helper.yml @@ -14,10 +14,6 @@ on: description: GitHub Release tag to upload assets to, for example v0.13.3. required: true type: string - checkout_ref: - description: Optional branch, tag, or commit SHA to build. Defaults to the selected workflow ref. - required: false - type: string permissions: contents: write @@ -27,7 +23,8 @@ jobs: name: Publish Android Snapshot Helper runs-on: blacksmith-4vcpu-ubuntu-2404 timeout-minutes: 30 - # The helper keystore secrets live only in the protected `release` environment. + # The helper keystore secrets live only in the protected `release` environment. Its deployment + # rule gates github.ref, so the job builds exactly that ref. environment: release env: AGENT_DEVICE_ANDROID_HELPER_RELEASE: '1' @@ -35,7 +32,7 @@ jobs: - name: Checkout uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2 with: - ref: ${{ inputs.checkout_ref || github.ref }} + ref: ${{ github.ref }} - name: Checkout release validator uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99f99e7bfc8..91d202235cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -105,7 +105,9 @@ jobs: persist-credentials: false ref: ${{ github.workflow_sha }} path: .release-tools - sparse-checkout: scripts/release-version.mjs + sparse-checkout: | + scripts/release-version.mjs + .github/actions/setup-android-helper-signing/action.yml sparse-checkout-cone-mode: false # No dependency cache: published bytes come from a clean install. @@ -120,7 +122,8 @@ jobs: - name: Setup Android helper signing if: needs.plan.outputs.mode != 'dry-run' - uses: ./.github/actions/setup-android-helper-signing + # From the workflow commit: the planned nightly source may predate this action. + uses: ./.release-tools/.github/actions/setup-android-helper-signing with: keystore-base64: ${{ secrets.ANDROID_HELPER_KEYSTORE_BASE64 }} keystore-password: ${{ secrets.ANDROID_HELPER_KEYSTORE_PASSWORD }} diff --git a/test/ci/release-workflow.test.ts b/test/ci/release-workflow.test.ts index d9f6a107898..ca76df0eacd 100644 --- a/test/ci/release-workflow.test.ts +++ b/test/ci/release-workflow.test.ts @@ -10,6 +10,7 @@ type Job = { 'cache-mode'?: string; 'runs-on'?: string; environment?: string; + env?: Record; permissions?: Record; steps?: Array<{ id?: string; @@ -55,6 +56,9 @@ test('the publisher authenticates through OIDC alone', () => { expect(workflow.jobs.build?.environment).toBe( "${{ needs.plan.outputs.mode != 'dry-run' && 'release' || '' }}", ); + expect(workflow.jobs.build?.env?.AGENT_DEVICE_ANDROID_HELPER_RELEASE).toBe( + "${{ needs.plan.outputs.mode != 'dry-run' && '1' || '' }}", + ); const withSecrets = Object.entries(workflow.jobs) .map(([name, job]) => [name, secretsOf(job)] as const) .filter(([, names]) => names.length > 0); @@ -97,6 +101,9 @@ test('the version stamping entrypoint is pinned to the workflow commit', () => { (step) => step.with?.path === '.release-tools', ); expect(entrypoint?.with?.ref).toBe('${{ github.workflow_sha }}'); + expect( + workflow.jobs.build?.steps?.find((step) => step.name === 'Setup Android helper signing')?.uses, + ).toBe('./.release-tools/.github/actions/setup-android-helper-signing'); }); test('both nightly schedules keep separate concurrency groups for cron and manual selection', () => { diff --git a/test/repo-guards/release-assets.test.ts b/test/repo-guards/release-assets.test.ts index c75768bc275..1306537d0d8 100644 --- a/test/repo-guards/release-assets.test.ts +++ b/test/repo-guards/release-assets.test.ts @@ -197,6 +197,7 @@ for (const workflow of workflows) { const repositories: Record> = { caller: { '${{ inputs.checkout_ref || github.ref }}': historical, + '${{ github.ref }}': historical, '${{ github.workflow_sha }}': historical, '${{ job.workflow_sha }}': historical, },