name: Release on: push: tags: - 'v*' # Tag pushes may build with read-only authority. Attestation and publication # opt into only the write capabilities required by their gated jobs. permissions: contents: read concurrency: group: release-${{ github.ref }} cancel-in-progress: false jobs: qualify: name: Qualify exact manual full CI runs-on: ubuntu-latest timeout-minutes: 50 permissions: contents: read actions: write outputs: run_id: ${{ steps.full.outputs.full_ci_run_id }} attempt: ${{ steps.full.outputs.full_ci_attempt }} source: ${{ steps.full.outputs.source_sha }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: 22 - name: Reuse or dispatch exact manual full CI once id: full env: GH_TOKEN: ${{ github.token }} RELEASE_TAG: ${{ github.ref_name }} run: node scripts/release/qualify-full-ci.mjs qualify build-and-verify: name: Build and verify release candidate needs: qualify uses: ./.github/workflows/release-build.yml with: release_tag: ${{ github.ref_name }} permissions: contents: read attest: name: Request artifact attestations if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: [qualify, build-and-verify] runs-on: ubuntu-latest env: RELEASE_TAG: ${{ github.ref_name }} FULL_CI_RUN_ID: ${{ needs.qualify.outputs.run_id }} FULL_CI_ATTEMPT: ${{ needs.qualify.outputs.attempt }} FULL_CI_SOURCE: ${{ needs.qualify.outputs.source }} permissions: contents: read actions: read id-token: write attestations: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: 22 - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: verified-release-bundle path: artifacts - name: Recheck full CI before request build provenance for the six exact archives env: GH_TOKEN: ${{ github.token }} run: node scripts/release/qualify-full-ci.mjs verify - name: Request build provenance for the six exact archives uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 with: subject-checksums: artifacts/SHA256SUMS - name: Recheck full CI before request sbom attestation for macos arm64 archive env: GH_TOKEN: ${{ github.token }} run: node scripts/release/qualify-full-ci.mjs verify - name: Request SBOM attestation for macOS arm64 archive uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 with: subject-path: artifacts/phantom-aarch64-apple-darwin/phantom-aarch64-apple-darwin.tar.gz sbom-path: artifacts/phantom-aarch64-apple-darwin/phantom-aarch64-apple-darwin.tar.gz.spdx.json - name: Recheck full CI before request sbom attestation for macos x64 archive env: GH_TOKEN: ${{ github.token }} run: node scripts/release/qualify-full-ci.mjs verify - name: Request SBOM attestation for macOS x64 archive uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 with: subject-path: artifacts/phantom-x86_64-apple-darwin/phantom-x86_64-apple-darwin.tar.gz sbom-path: artifacts/phantom-x86_64-apple-darwin/phantom-x86_64-apple-darwin.tar.gz.spdx.json - name: Recheck full CI before request sbom attestation for linux arm64 archive env: GH_TOKEN: ${{ github.token }} run: node scripts/release/qualify-full-ci.mjs verify - name: Request SBOM attestation for Linux arm64 archive uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 with: subject-path: artifacts/phantom-aarch64-unknown-linux-gnu/phantom-aarch64-unknown-linux-gnu.tar.gz sbom-path: artifacts/phantom-aarch64-unknown-linux-gnu/phantom-aarch64-unknown-linux-gnu.tar.gz.spdx.json - name: Recheck full CI before request sbom attestation for linux x64 archive env: GH_TOKEN: ${{ github.token }} run: node scripts/release/qualify-full-ci.mjs verify - name: Request SBOM attestation for Linux x64 archive uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 with: subject-path: artifacts/phantom-x86_64-unknown-linux-gnu/phantom-x86_64-unknown-linux-gnu.tar.gz sbom-path: artifacts/phantom-x86_64-unknown-linux-gnu/phantom-x86_64-unknown-linux-gnu.tar.gz.spdx.json - name: Recheck full CI before request sbom attestation for windows arm64 archive env: GH_TOKEN: ${{ github.token }} run: node scripts/release/qualify-full-ci.mjs verify - name: Request SBOM attestation for Windows arm64 archive uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 with: subject-path: artifacts/phantom-aarch64-pc-windows-msvc/phantom-aarch64-pc-windows-msvc.zip sbom-path: artifacts/phantom-aarch64-pc-windows-msvc/phantom-aarch64-pc-windows-msvc.zip.spdx.json - name: Recheck full CI before request sbom attestation for windows x64 archive env: GH_TOKEN: ${{ github.token }} run: node scripts/release/qualify-full-ci.mjs verify - name: Request SBOM attestation for Windows x64 archive uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 with: subject-path: artifacts/phantom-x86_64-pc-windows-msvc/phantom-x86_64-pc-windows-msvc.zip sbom-path: artifacts/phantom-x86_64-pc-windows-msvc/phantom-x86_64-pc-windows-msvc.zip.spdx.json verify-attestations: name: Verify release attestations if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: attest runs-on: ubuntu-latest permissions: contents: read attestations: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: verified-release-bundle path: artifacts - name: Re-verify the exact attested artifact set run: node scripts/release/verify-release-artifacts.mjs artifacts - name: Verify build provenance and SPDX attestations before release approval env: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail for archive in \ phantom-aarch64-apple-darwin.tar.gz \ phantom-x86_64-apple-darwin.tar.gz \ phantom-aarch64-unknown-linux-gnu.tar.gz \ phantom-x86_64-unknown-linux-gnu.tar.gz \ phantom-aarch64-pc-windows-msvc.zip \ phantom-x86_64-pc-windows-msvc.zip; do mapfile -t matches < <(find artifacts -type f -name "$archive" -print) test "${#matches[@]}" -eq 1 archive_path="${matches[0]}" gh attestation verify "$archive_path" \ --repo "$GITHUB_REPOSITORY" \ --signer-workflow "$GITHUB_REPOSITORY/.github/workflows/release.yml" \ --signer-digest "$GITHUB_SHA" \ --source-ref "$GITHUB_REF" \ --source-digest "$GITHUB_SHA" \ --deny-self-hosted-runners >/dev/null gh attestation verify "$archive_path" \ --repo "$GITHUB_REPOSITORY" \ --signer-workflow "$GITHUB_REPOSITORY/.github/workflows/release.yml" \ --signer-digest "$GITHUB_SHA" \ --source-ref "$GITHUB_REF" \ --source-digest "$GITHUB_SHA" \ --predicate-type "https://spdx.dev/Document/v2.3" \ --deny-self-hosted-runners >/dev/null done release: name: Create Release if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: [qualify, verify-attestations] runs-on: ubuntu-latest env: RELEASE_TAG: ${{ github.ref_name }} FULL_CI_RUN_ID: ${{ needs.qualify.outputs.run_id }} FULL_CI_ATTEMPT: ${{ needs.qualify.outputs.attempt }} FULL_CI_SOURCE: ${{ needs.qualify.outputs.source }} # Configure this environment in GitHub with a required human reviewer. # Tags may build, attest, and verify, but publication keeps a separate # approval gate. environment: name: release # Release job needs write to publish the Release and upload assets. permissions: contents: write actions: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: verified-release-bundle path: artifacts - name: Verify exact release artifact set run: node scripts/release/verify-release-artifacts.mjs artifacts - name: Extract reviewed release notes run: node scripts/release/extract-release-notes.mjs "$GITHUB_REF_NAME" > release-notes.md - name: Re-verify release tag binding and absence immediately before creation env: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail test "$GITHUB_REF" = "refs/tags/$GITHUB_REF_NAME" node scripts/release/verify-github-tag-binding.mjs "$GITHUB_REF_NAME" "$GITHUB_SHA" status=$(curl --proto '=https' --tlsv1.2 --fail-with-body --silent --show-error \ --connect-timeout 10 --max-time 30 \ --header "Accept: application/vnd.github+json" \ --header "Authorization: Bearer ${GH_TOKEN}" \ --output /tmp/phantom-release-preflight.json \ --write-out '%{http_code}' \ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${GITHUB_REF_NAME}" || true) case "$status" in 404) ;; 200) echo "release ${GITHUB_REF_NAME} already exists; publish a new fix-forward tag" >&2; exit 1 ;; *) echo "could not prove release absence (HTTP ${status:-none})" >&2; exit 1 ;; esac node scripts/release/qualify-full-ci.mjs verify - name: Create release id: create-draft-release uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 with: body_path: release-notes.md draft: true generate_release_notes: true overwrite_files: false fail_on_unmatched_files: true files: | artifacts/**/*.tar.gz artifacts/**/*.zip artifacts/**/*.sha256 artifacts/**/*.spdx.json artifacts/SHA256SUMS - name: Verify the complete draft release receipt env: GH_TOKEN: ${{ github.token }} run: | gh release view "$GITHUB_REF_NAME" \ --json tagName,isDraft,isImmutable,isPrerelease,assets,url > release-receipt.json node scripts/release/verify-github-release-receipt.mjs \ release-receipt.json "$GITHUB_REF_NAME" draft - name: Verify hosted draft artifacts match the trusted build env: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail hosted_dir=$(mktemp -d) trap 'rm -rf "$hosted_dir"' EXIT gh release download "$GITHUB_REF_NAME" --dir "$hosted_dir" node scripts/release/verify-release-artifacts.mjs "$hosted_dir" node scripts/release/compare-release-artifacts.mjs artifacts "$hosted_dir" # The Ashlr organization enforces immutable releases for this selected # repository. The administration-read policy endpoint is intentionally # unavailable to the job token; the hosted receipt below still requires # GitHub to report isImmutable=true after publication. - name: Publish the organization-enforced immutable release env: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail node scripts/release/qualify-full-ci.mjs verify gh release edit "$GITHUB_REF_NAME" --draft=false - name: Verify the published immutable release receipt env: GH_TOKEN: ${{ github.token }} run: | gh release view "$GITHUB_REF_NAME" \ --json tagName,isDraft,isImmutable,isPrerelease,assets,url > release-receipt.json node scripts/release/verify-github-release-receipt.mjs \ release-receipt.json "$GITHUB_REF_NAME" published - name: Re-verify hosted immutable release artifacts env: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail hosted_dir=$(mktemp -d) trap 'rm -rf "$hosted_dir"' EXIT gh release download "$GITHUB_REF_NAME" --dir "$hosted_dir" node scripts/release/verify-release-artifacts.mjs "$hosted_dir" node scripts/release/compare-release-artifacts.mjs artifacts "$hosted_dir" npm-publish: name: Publish npm packages (trusted publishing) # Release tags only. Runs after the GitHub Release is created and # re-verified, behind the same human-reviewed `release` environment. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: [qualify, release] runs-on: ubuntu-latest env: RELEASE_TAG: ${{ github.ref_name }} FULL_CI_RUN_ID: ${{ needs.qualify.outputs.run_id }} FULL_CI_ATTEMPT: ${{ needs.qualify.outputs.attempt }} FULL_CI_SOURCE: ${{ needs.qualify.outputs.source }} environment: name: release # OIDC trusted publishing: npm exchanges the GitHub id-token for a # short-lived publish credential. No NPM_TOKEN secret is used. permissions: contents: read actions: read id-token: write strategy: max-parallel: 1 matrix: package: - { dir: npm, name: phantom-secrets } - { dir: npm-mcp, name: phantom-secrets-mcp } steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: '24' - name: Use a pinned npm with trusted publishing support (11.19.0, >= 11.15) run: | set -euo pipefail npm install --global npm@11.19.0 npm --version - name: Verify package name and version match the tag env: PKG_DIR: ${{ matrix.package.dir }} PKG_NAME: ${{ matrix.package.name }} run: | set -euo pipefail name=$(node -p "require('./${PKG_DIR}/package.json').name") version=$(node -p "require('./${PKG_DIR}/package.json').version") test "$name" = "$PKG_NAME" test "v${version}" = "$GITHUB_REF_NAME" if [ -n "${NODE_AUTH_TOKEN:-}" ] || [ -n "${NPM_TOKEN:-}" ]; then echo "::error::token-based npm auth must not be configured"; exit 1 fi - name: Publish with provenance working-directory: ${{ matrix.package.dir }} env: PKG_NAME: ${{ matrix.package.name }} GH_TOKEN: ${{ github.token }} run: | set -euo pipefail version=$(node -p "require('./package.json').version") if npm view "${PKG_NAME}@${version}" version >/dev/null 2>&1; then echo "${PKG_NAME}@${version} is already published; skipping." exit 0 fi node ../scripts/release/qualify-full-ci.mjs verify npm publish --provenance --access public