Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/actions/setup-android-helper-signing/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup Android helper signing
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.
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"
18 changes: 13 additions & 5 deletions .github/workflows/release-android-snapshot-helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,11 +23,16 @@ 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. Its deployment
# rule gates github.ref, so the job builds exactly that ref.
environment: release
env:
AGENT_DEVICE_ANDROID_HELPER_RELEASE: '1'
steps:
- 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
Expand Down Expand Up @@ -64,6 +65,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 }}
Comment thread
thymikee marked this conversation as resolved.
Resolved
Comment thread
thymikee marked this conversation as resolved.
Resolved
keystore-password: ${{ secrets.ANDROID_HELPER_KEYSTORE_PASSWORD }}

- name: Check Java toolchain
run: |
javac --version
Expand All @@ -76,6 +83,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}"
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -100,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.
Expand All @@ -113,10 +120,20 @@ jobs:
- name: Setup Android SDK
uses: ./.github/actions/setup-android-sdk

- name: Setup Android helper signing
if: needs.plan.outputs.mode != 'dry-run'
# 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 }}

- name: Stamp release version
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
Expand Down Expand Up @@ -281,7 +298,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]
Expand Down
28 changes: 22 additions & 6 deletions test/ci/release-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Job = {
'cache-mode'?: string;
'runs-on'?: string;
environment?: string;
env?: Record<string, string>;
permissions?: Record<string, string>;
steps?: Array<{
id?: string;
Expand Down Expand Up @@ -40,19 +41,31 @@ 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/);
// 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(
Comment thread
thymikee marked this conversation as resolved.
Resolved
"${{ 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);
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@'),
);
Expand Down Expand Up @@ -88,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', () => {
Expand Down
1 change: 1 addition & 0 deletions test/repo-guards/release-assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ for (const workflow of workflows) {
const repositories: Record<string, Record<string, string>> = {
caller: {
'${{ inputs.checkout_ref || github.ref }}': historical,
'${{ github.ref }}': historical,
'${{ github.workflow_sha }}': historical,
'${{ job.workflow_sha }}': historical,
},
Expand Down
Loading