Skip to content
Draft
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
77 changes: 5 additions & 72 deletions .github/workflows/opensecret-eif-release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
name: OpenSecret EIF release

# Builds one environment's EIF candidate and attests it. For prod, behind the
# reviewer-gated pcr-signing environment, it signs and appends the approval with
# the same recipe operators use; the result is a review branch for an ordinary
# pull request. A dev build is approved by opensecret-release-statement-dev.yml,
# whose one gated job signs both the release statement and the legacy approval.
# This workflow never creates a GitHub Release or tag: /releases/latest and the
# desktop updater metadata belong to the Maple app.
# Deployment stays manual. The legacy repository copy of the signed PCR files
# is retired (services/opensecret/docs/pcr-compatibility.md).
# Builds and attests one environment's EIF candidate. Approval happens in the
# corresponding opensecret-release-statement workflow, where one reviewer-gated
# job signs both the legacy PCR0 approval and the Sigstore release statement.
# Deployment stays manual; this workflow never creates a Release or tag.

on:
workflow_dispatch:
inputs:
environment:
description: Measurement set to build and approve
description: Measurement set to build
type: choice
options: [dev, prod]
required: true
dry_run:
description: Build, attest and compare only; uncheck to sign prod after environment approval (dev is signed by the Dev release statement workflow)
type: boolean
default: true
required: true

permissions:
contents: read
Expand Down Expand Up @@ -90,60 +80,3 @@ jobs:
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-checksums: eif-artifact/SHA256SUMS

sign:
name: Sign and append approval (${{ inputs.environment }})
needs: build
# Dev approvals come only from the Dev release statement workflow, so one
# review covers both of its signatures and nothing signs Dev twice.
if: inputs.environment == 'prod' && inputs.dry_run == false && needs.build.outputs.approval_needed == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
# Required reviewer approval and the master-only branch policy live on the
# environment; the only secret it holds is a read-only BWS machine token.
environment: pcr-signing
permissions:
contents: write
env:
APPROVAL_ARTIFACT: ${{ needs.build.outputs.artifact }}
EXPECTED_EIF_SHA256: ${{ needs.build.outputs.eif_sha256 }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: recursive
fetch-depth: 0

- name: Install pinned Nix
uses: DeterminateSystems/determinate-nix-action@16f94ba7aae399b9f9077c254b6719ec6de7e3e3 # v3.24.2
with:
source-tag: v3.24.2
github-token: ""

- name: Verify pinned Nix runtime
run: bash scripts/ci/verify-nix-runtime.sh

- name: Download the attested EIF candidate
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: ${{ env.APPROVAL_ARTIFACT }}
path: eif-artifact

- name: Resolve the existing signing key from Bitwarden Secrets Manager
id: signing-key
uses: bitwarden/sm-action@1238aae8fc64b212641190a9227c8a734ab1a793 # v3.0.1
with:
access_token: ${{ secrets.OPENSECRET_PCR_SIGNING_BWS_ACCESS_TOKEN }}
secrets: |
${{ vars.OPENSECRET_PCR_SIGNING_KEY_ID }} > SIGNING_PRIVATE_KEY
set_env: false

- name: Sign PCR0 and append the verified approval
env:
SIGNING_PRIVATE_KEY: ${{ steps.signing-key.outputs.SIGNING_PRIVATE_KEY }}
run: nix develop --no-update-lock-file './services/opensecret?submodules=1#signing' -c bash services/opensecret/scripts/ci_sign_pcr.sh "$EIF_MODE" eif-artifact

- name: Push the approval branch for review
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bash scripts/ci/publish_opensecret_approval.sh "$EIF_MODE" eif-artifact
34 changes: 19 additions & 15 deletions .github/workflows/opensecret-release-statement-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ run-name: Dev release statement for build run ${{ inputs.build_run_id }}
# Sigstore release statement with the Dev KMS key and the legacy PCR0 approval
# with the existing key, so one review covers both; publishes the bundle to the
# Dev attestation host; and pushes the legacy approval branch for review. The
# environment, key, bucket and host are fixed here, never inputs. See
# environment and key are fixed here; bucket and host are fixed per mode in
# scripts/ci/opensecret_release_statement.py. None are inputs. See
# services/opensecret/docs/release-statements.md.

on:
Expand Down Expand Up @@ -61,9 +62,12 @@ jobs:

- uses: ./.github/actions/setup-nix

- name: Refuse to run with an incomplete signing identity
- name: Check the signing identity and public storage settings
env:
ATTESTATIONS_R2_ACCOUNT_ID: ${{ vars.ATTESTATIONS_R2_ACCOUNT_ID }}
ATTESTATIONS_R2_BUCKET: ${{ vars.ATTESTATIONS_R2_BUCKET }}
run: >-
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3 nixpkgs#yq-go
-c python3 -I scripts/ci/opensecret_release_statement.py preflight dev

- name: Verify the selected Dev build and prepare its statement
Expand All @@ -79,6 +83,16 @@ jobs:
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3
-c python3 -I scripts/ci/opensecret_release_statement.py install-cosign "$RUNNER_TEMP/cosign"

- name: Resolve the Dev bucket publisher credential
id: publisher
uses: bitwarden/sm-action@1238aae8fc64b212641190a9227c8a734ab1a793 # v3.0.1
with:
access_token: ${{ secrets.OPENSECRET_PCR_SIGNING_BWS_ACCESS_TOKEN }}
secrets: |
${{ vars.ATTESTATIONS_R2_ACCESS_KEY_ID_SECRET_ID }} > AWS_ACCESS_KEY_ID
${{ vars.ATTESTATIONS_R2_SECRET_ACCESS_KEY_SECRET_ID }} > AWS_SECRET_ACCESS_KEY
set_env: false

- name: Resolve the existing PCR signing key
id: signing-key
uses: bitwarden/sm-action@1238aae8fc64b212641190a9227c8a734ab1a793 # v3.0.1
Expand All @@ -96,7 +110,7 @@ jobs:

- name: Sign the release statement with the Dev KMS key
run: >-
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3 nixpkgs#yq-go
-c python3 -I scripts/ci/opensecret_release_statement.py sign dev candidate release "$RUNNER_TEMP/cosign/cosign"

- name: Retain the EIF with its original bundle
Expand All @@ -109,16 +123,6 @@ jobs:
if-no-files-found: error
retention-days: 90

- name: Resolve the Dev bucket publisher credential
id: publisher
uses: bitwarden/sm-action@1238aae8fc64b212641190a9227c8a734ab1a793 # v3.0.1
with:
access_token: ${{ secrets.OPENSECRET_PCR_SIGNING_BWS_ACCESS_TOKEN }}
secrets: |
${{ vars.ATTESTATIONS_R2_ACCESS_KEY_ID_SECRET_ID }} > AWS_ACCESS_KEY_ID
${{ vars.ATTESTATIONS_R2_SECRET_ACCESS_KEY_SECRET_ID }} > AWS_SECRET_ACCESS_KEY
set_env: false

- name: Publish the bundle and verify the public bytes
env:
AWS_ACCESS_KEY_ID: ${{ steps.publisher.outputs.AWS_ACCESS_KEY_ID }}
Expand All @@ -133,4 +137,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXPECTED_SOURCE_SHA: ${{ steps.candidate.outputs.source_sha }}
run: bash scripts/ci/publish_opensecret_approval.sh dev candidate
run: nix develop --no-update-lock-file './services/opensecret?submodules=1#signing' -c bash scripts/ci/publish_opensecret_approval.sh dev candidate
140 changes: 140 additions & 0 deletions .github/workflows/opensecret-release-statement-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: OpenSecret Production release statement
# Shown on the run list and the reviewer's approval screen, so the reviewer can
# see which build they are approving.
run-name: Production release statement for build run ${{ inputs.build_run_id }}

# Approves one verified Production EIF build. Its single reviewer-gated job signs the
# Sigstore release statement with the Production KMS key and the legacy PCR0 approval
# with the existing key, so one review covers both; publishes the bundle to the
# Production attestation host; and pushes the legacy approval branch for review. The
# environment and key are fixed here; bucket and host are fixed per mode in
# scripts/ci/opensecret_release_statement.py. None are inputs. See
# services/opensecret/docs/release-statements.md.

on:
workflow_dispatch:
inputs:
build_run_id:
description: Run ID of a successful master OpenSecret EIF release run built for prod
type: string
required: true

permissions:
contents: read

concurrency:
group: opensecret-release-statement-prod
cancel-in-progress: false

jobs:
sign:
name: Verify, sign and publish the Production release statement
if: github.repository == 'MaplePrivacyLabs/Maple' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
timeout-minutes: 60
# Required reviewers and the master-only branch rule live on the environment.
# It also scopes the AWS role (its OIDC subject names this environment) and
# holds this environment's own BWS machine token, which reads only the legacy
# signing key and the Production bucket's publisher credential.
environment: pcr-signing-prod
permissions:
contents: write
actions: read
attestations: read
id-token: write
env:
OPENSECRET_DEV_POSTGRES: "0"
OPENSECRET_DEV_ENV: "0"
OPENSECRET_DEV_CONTAINERS: "0"
BUILD_RUN_ID: ${{ inputs.build_run_id }}
# The Production approval key, by full ARN (never an alias), and the only role its
# policy lets sign. The preflight step fails the job while these are
# placeholders or the reviewed public key below is not committed.
SIGNING_KEY_ARN: REPLACE_ME_PROD_KMS_KEY_ARN
SIGNER_ROLE_ARN: REPLACE_ME_PROD_SIGNER_ROLE_ARN
SIGNING_PUBLIC_KEY: scripts/ci/opensecret-release/prod-signing-key.pem
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: recursive
fetch-depth: 0

- uses: ./.github/actions/setup-nix

- name: Check the signing identity and public storage settings
env:
ATTESTATIONS_R2_ACCOUNT_ID: ${{ vars.ATTESTATIONS_R2_ACCOUNT_ID }}
ATTESTATIONS_R2_BUCKET: ${{ vars.ATTESTATIONS_R2_BUCKET }}
run: >-
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3 nixpkgs#yq-go
-c python3 -I scripts/ci/opensecret_release_statement.py preflight prod

- name: Verify the selected Production build and prepare its statement
id: candidate
env:
GH_TOKEN: ${{ github.token }}
run: >-
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3 nixpkgs#gh
-c python3 -I scripts/ci/opensecret_release_statement.py prepare prod "$BUILD_RUN_ID" candidate release

- name: Install the pinned Cosign release
run: >-
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3
-c python3 -I scripts/ci/opensecret_release_statement.py install-cosign "$RUNNER_TEMP/cosign"

- name: Resolve the Production bucket publisher credential
id: publisher
uses: bitwarden/sm-action@1238aae8fc64b212641190a9227c8a734ab1a793 # v3.0.1
with:
access_token: ${{ secrets.OPENSECRET_PCR_SIGNING_BWS_ACCESS_TOKEN }}
secrets: |
${{ vars.ATTESTATIONS_R2_ACCESS_KEY_ID_SECRET_ID }} > AWS_ACCESS_KEY_ID
${{ vars.ATTESTATIONS_R2_SECRET_ACCESS_KEY_SECRET_ID }} > AWS_SECRET_ACCESS_KEY
set_env: false

- name: Resolve the existing PCR signing key
id: signing-key
uses: bitwarden/sm-action@1238aae8fc64b212641190a9227c8a734ab1a793 # v3.0.1
with:
access_token: ${{ secrets.OPENSECRET_PCR_SIGNING_BWS_ACCESS_TOKEN }}
secrets: |
${{ vars.OPENSECRET_PCR_SIGNING_KEY_ID }} > SIGNING_PRIVATE_KEY
set_env: false

- name: Sign the same candidate for legacy clients
env:
SIGNING_PRIVATE_KEY: ${{ steps.signing-key.outputs.SIGNING_PRIVATE_KEY }}
EXPECTED_EIF_SHA256: ${{ steps.candidate.outputs.eif_sha256 }}
run: nix develop --no-update-lock-file './services/opensecret?submodules=1#signing' -c bash services/opensecret/scripts/ci_sign_pcr.sh prod candidate

- name: Sign the release statement with the Production KMS key
run: >-
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3 nixpkgs#yq-go
-c python3 -I scripts/ci/opensecret_release_statement.py sign prod candidate release "$RUNNER_TEMP/cosign/cosign"

- name: Retain the EIF with its original bundle
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: opensecret-approved-prod-${{ steps.candidate.outputs.source_sha }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
candidate
release
if-no-files-found: error
retention-days: 90

- name: Publish the bundle and verify the public bytes
env:
AWS_ACCESS_KEY_ID: ${{ steps.publisher.outputs.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ steps.publisher.outputs.AWS_SECRET_ACCESS_KEY }}
ATTESTATIONS_R2_ACCOUNT_ID: ${{ vars.ATTESTATIONS_R2_ACCOUNT_ID }}
ATTESTATIONS_R2_BUCKET: ${{ vars.ATTESTATIONS_R2_BUCKET }}
run: >-
nix shell --no-update-lock-file --inputs-from . nixpkgs#python3 nixpkgs#awscli2
-c python3 -I scripts/ci/opensecret_release_statement.py publish prod candidate release "$RUNNER_TEMP/cosign/cosign"

- name: Push the legacy approval branch for review
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXPECTED_SOURCE_SHA: ${{ steps.candidate.outputs.source_sha }}
run: nix develop --no-update-lock-file './services/opensecret?submodules=1#signing' -c bash scripts/ci/publish_opensecret_approval.sh prod candidate
6 changes: 6 additions & 0 deletions docs/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ from stdin. It applies no labels, and it lists `os-eif` for any EIF input
without the same-repository and base-`master` checks (it does drop it for a
PCR approval edit).

The `repo` lane also runs the legacy signing regressions with explicitly listed
binary-cache tools from the root's locked nixpkgs. It does not enter the
OpenSecret development shell or build a patched Git. Missing tools fail this
CI step. Tests use local fixtures; local harness verification additionally cuts
off networking. The lane uses an ordinary shallow checkout and no submodules.

## Tiers

| When | What runs |
Expand Down
2 changes: 1 addition & 1 deletion docs/repository-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ the other side of each contract. A failure means the workflow change is wrong:
1. `release.yml` and the publishers (`pages-publish`, `proxy-publish`,
`updates-publish`, `sdk-publish-npm`, `sdk-publish-rust`,
`auth-pages-publish`, `opensecret-eif-release`,
`opensecret-release-statement-dev`)
`opensecret-release-statement-dev`, `opensecret-release-statement-prod`)
change only with owner review. Exactly one workflow is named `Release`, and
every `workflow_run` listener names its producer and checks the head
repository, conclusion and event.
Expand Down
16 changes: 13 additions & 3 deletions scripts/ci/lanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def cache_store(label: str) -> str:
return "blacksmith" if label.startswith("blacksmith-") else "github"


SIGNING_TEST_RUN = (
"nix shell --no-update-lock-file --impure --file scripts/ci/signing-test-tools.nix"
" -c env CI=true PYTHONDONTWRITEBYTECODE=1 python3 -B -I -m unittest discover"
" -s scripts/ci -p test_opensecret_legacy_signing.py"
)

# The override variables are unset; set one to fail over during an outage.
LINUX = Runner("blacksmith-8vcpu-ubuntu-2404", "CI_LINUX_RUNNER")
LINUX_HEAVY = Runner("blacksmith-32vcpu-ubuntu-2404", "CI_LINUX_HEAVY_RUNNER")
Expand Down Expand Up @@ -307,14 +313,18 @@ def deny(manifest: str, component: str) -> str:
run=WINDOWS_PACKAGE,
env=(("MAPLE_WINDOWS_ARCH", "aarch64"), ("RUSTFLAGS", "-D warnings -C target-feature=+crt-static")) + FAST_RELEASE,
timeout=120, gate=False),
# Every root flake check: actionlint, workflow policy and contracts, CI script
# tests, the release gates, and release metadata (read from the version files).
# Root flake checks cover workflows, CI contracts, release gates and metadata.
# Legacy signing also runs with explicit cached tools; missing tools fail CI.
Lane("repo", (
".github/**", "scripts/ci/**", ".githooks/**", "flake.nix", "flake.lock", "justfile", "setup-hooks.sh",
".agents/skills/release-maple/scripts/**",
"scripts/update-version.py", "proxy/Cargo.toml", "proxy/justfile",
RESEARCH + "package.json", TAURI + "Cargo.toml", TAURI + "tauri.conf.json",
), runner=GITHUB, run="nix flake check --no-update-lock-file --print-build-logs", timeout=15, hook="repo"),
"services/opensecret/scripts/ci_sign_pcr.sh", "services/opensecret/justfile",
"services/opensecret/scripts/pcr_compatibility.py", "services/opensecret/pcr_sign.js",
), runner=GITHUB,
run="nix flake check --no-update-lock-file --print-build-logs && " + SIGNING_TEST_RUN,
timeout=15, hook="repo"),

# The SDKs, proxy and container. build-sdk-publish.sh is the publishers' own builder.
Lane("sdk-ts", SDK_TS + ("sdk/.prettierrc.json", "sdk/eslint.config.js", "sdk/justfile", "sdk/.env.example",
Expand Down
Loading
Loading