name: Release build and verification on: workflow_call: inputs: release_tag: description: Exact v-prefixed SemVer to rehearse against the checked-out source required: true type: string # This graph is deliberately reusable and value-producing only. It cannot # attest, publish, or mutate repository contents. permissions: contents: read env: PHANTOM_RELEASE_TAG: ${{ inputs.release_tag }} PHANTOM_NPM_AUDIT_VERSION: 11.15.0 jobs: verify-source: name: Verify source and release contract runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false fetch-depth: 0 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: 22 - name: Reject tracked dependency installations shell: bash run: | set -euo pipefail /usr/bin/git ls-files -z | node scripts/release/check-dependency-index.mjs - name: Fetch canonical origin heads for history policy run: git fetch --no-tags --prune origin '+refs/heads/*:refs/remotes/origin/*' - name: Verify immutable annotated release tag binding if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') run: | test "$GITHUB_REF" = "refs/tags/$GITHUB_REF_NAME" node scripts/release/verify-github-tag-binding.mjs "$GITHUB_REF_NAME" "$GITHUB_SHA" # Run before dependency/cache restoration so this scans the checked-out # source tree rather than generated target, node_modules, or .next files. - name: Install verified Gitleaks env: GITLEAKS_VERSION: 8.30.0 GITLEAKS_SHA256: 79a3ab579b53f71efd634f3aaf7e04a0fa0cf206b7ed434638d1547a2470a66e run: | set -euo pipefail archive="/tmp/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" install_dir="/tmp/phantom-gitleaks-bin" mkdir -p "$install_dir" curl --proto '=https' --proto-redir '=https' --tlsv1.2 --fail --location --silent --show-error \ --max-redirs 3 --connect-timeout 10 --max-time 120 --max-filesize 134217728 \ --output "$archive" \ "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" echo "${GITLEAKS_SHA256} ${archive}" | sha256sum --check --strict - tar -xzf "$archive" -C "$install_dir" gitleaks "$install_dir/gitleaks" version - name: Scan current source with the reviewed fixture policy run: /tmp/phantom-gitleaks-bin/gitleaks dir . --config .gitleaks.toml --redact --no-banner --max-target-megabytes 5 --timeout 60 - name: Validate exact candidate and canonical-origin history policy run: | node --test scripts/release/validate-gitleaks-ignore.test.mjs node scripts/release/validate-gitleaks-ignore.mjs .gitleaksignore HEAD - name: Scan candidate and canonical origin ancestry against reviewed fingerprints run: /tmp/phantom-gitleaks-bin/gitleaks git . --log-opts='HEAD --remotes=origin' --config .gitleaks.toml --gitleaks-ignore-path .gitleaksignore --redact --no-banner --max-target-megabytes 5 --timeout 120 - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable (2026-04-24) with: toolchain: 1.95.0 components: rustfmt, clippy - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: 22 cache: npm cache-dependency-path: apps/web/package-lock.json - name: Verify release version parity run: | node scripts/release/check-version-parity.mjs "$PHANTOM_RELEASE_TAG" node scripts/release/extract-release-notes.mjs "$PHANTOM_RELEASE_TAG" > /tmp/phantom-release-notes.md - name: Test fail-closed publication and release receipts run: node --test scripts/examples-first-five-minutes.test.mjs scripts/publish-crates.test.js scripts/release/check-glibc-baseline.test.mjs scripts/release/compare-release-artifacts.test.mjs scripts/release/extract-release-notes.test.mjs scripts/release/native-installer-acceptance.test.mjs scripts/release/native-release-smoke.test.mjs scripts/release/pre-tag-preflight.test.mjs scripts/release/readme-mcp-catalog.test.mjs scripts/release/release-receipts.test.mjs scripts/release/release-rehearsal-contract.test.mjs scripts/release/verify-github-tag-binding.test.mjs - name: Install checksum-verified MCP Registry publisher run: bash scripts/release/install-mcp-publisher.sh - name: Validate the staged MCP Registry manifest run: /tmp/phantom-mcp-publisher-bin/mcp-publisher validate mcp-registry/server.json - name: Install verified cargo-deny env: CARGO_DENY_VERSION: 0.20.2 CARGO_DENY_SHA256: 9f12ed4c49936e09b48bf862b595cde2fe64fcbd9d74dfacac6131ca824c8d5f run: | set -euo pipefail archive="/tmp/cargo-deny-${CARGO_DENY_VERSION}.tar.gz" install_dir="/tmp/phantom-cargo-deny-bin" mkdir -p "$install_dir" curl --proto '=https' --proto-redir '=https' --tlsv1.2 --fail --location --silent --show-error \ --max-redirs 3 --connect-timeout 10 --max-time 120 --max-filesize 134217728 \ --output "$archive" \ "https://github.com/EmbarkStudios/cargo-deny/releases/download/${CARGO_DENY_VERSION}/cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl.tar.gz" echo "${CARGO_DENY_SHA256} ${archive}" | sha256sum --check --strict - tar -xzf "$archive" -C "$install_dir" --strip-components=1 cargo-deny-${CARGO_DENY_VERSION}-x86_64-unknown-linux-musl/cargo-deny "$install_dir/cargo-deny" --version - name: Enforce Rust dependency policy run: /tmp/phantom-cargo-deny-bin/cargo-deny --all-features --locked check --deny warnings advisories licenses bans sources - name: Test workspace (locked) run: cargo test --workspace --all-targets --locked --no-fail-fast - name: Check formatting run: cargo fmt --all -- --check - name: Clippy (locked) run: cargo clippy --workspace --all-targets --locked -- -D warnings - name: Verify platform and direct installer contracts run: | node scripts/check-platform-installers.mjs node --test scripts/installers.test.js scripts/release/native-installer-acceptance.test.mjs - name: Test and inspect primary npm wrapper working-directory: npm run: | npm test npm pack --dry-run - name: Test and inspect npm MCP wrapper working-directory: npm-mcp run: | npm test npm pack --dry-run - name: Install web dependencies from the lockfile working-directory: apps/web run: npm ci --no-audit - name: Install the exact npm audit CLI run: | npm install \ --prefix "${RUNNER_TEMP}/phantom-npm-audit" \ --cache "${RUNNER_TEMP}/phantom-npm-audit-cache" \ --registry=https://registry.npmjs.org/ \ --ignore-scripts \ --no-audit \ --no-fund \ --no-save \ --package-lock=false \ "npm@${PHANTOM_NPM_AUDIT_VERSION}" "${RUNNER_TEMP}/phantom-npm-audit/node_modules/.bin/npm" --version | grep -Fx "${PHANTOM_NPM_AUDIT_VERSION}" - name: Audit production web dependencies working-directory: apps/web run: >- "${RUNNER_TEMP}/phantom-npm-audit/node_modules/.bin/npm" audit --omit=dev --audit-level=moderate - name: Lint web source working-directory: apps/web run: npm run lint - name: Run web security and auth tests working-directory: apps/web run: npm test - name: Build the production web application working-directory: apps/web run: npm run build - name: Build MCP release smoke binary (locked) run: cargo build --release --locked -p phantom-secrets-mcp --bin phantom-mcp - name: Deep MCP stdio schema smoke run: node scripts/release/mcp-stdio-smoke.mjs ./target/release/phantom-mcp 54 - name: Package every crates.io crate in dependency order run: ./scripts/publish-crates.sh --verify-only --version "${PHANTOM_RELEASE_TAG#v}" build: name: Build (${{ matrix.target }}) needs: verify-source runs-on: ${{ matrix.os }} # Build doesn't push anywhere — read-only token. permissions: contents: read strategy: fail-fast: false matrix: # Host archives and literal digests come from the immutable Syft 1.42.3 # release's syft_1.42.3_checksums.txt. Do not fetch a mutable installer. include: - target: x86_64-apple-darwin os: macos-latest artifact: phantom-x86_64-apple-darwin archive: phantom-x86_64-apple-darwin.tar.gz runner_os: macOS runner_arch: ARM64 syft_archive: syft_1.42.3_darwin_arm64.tar.gz syft_sha256: d71ee7db2be0fe2e96f679fd9d69ef04274cc86c8604707797080a21070b3f32 - target: aarch64-apple-darwin os: macos-latest artifact: phantom-aarch64-apple-darwin archive: phantom-aarch64-apple-darwin.tar.gz runner_os: macOS runner_arch: ARM64 syft_archive: syft_1.42.3_darwin_arm64.tar.gz syft_sha256: d71ee7db2be0fe2e96f679fd9d69ef04274cc86c8604707797080a21070b3f32 - target: x86_64-unknown-linux-gnu os: ubuntu-22.04 artifact: phantom-x86_64-unknown-linux-gnu archive: phantom-x86_64-unknown-linux-gnu.tar.gz runner_os: Linux runner_arch: X64 syft_archive: syft_1.42.3_linux_amd64.tar.gz syft_sha256: 0d6be741479eddd2c8644a288990c04f3df0d609bbc1599a005532a9dff63509 - target: aarch64-unknown-linux-gnu os: ubuntu-22.04 artifact: phantom-aarch64-unknown-linux-gnu archive: phantom-aarch64-unknown-linux-gnu.tar.gz runner_os: Linux runner_arch: X64 syft_archive: syft_1.42.3_linux_amd64.tar.gz syft_sha256: 0d6be741479eddd2c8644a288990c04f3df0d609bbc1599a005532a9dff63509 - target: x86_64-pc-windows-msvc os: windows-latest artifact: phantom-x86_64-pc-windows-msvc archive: phantom-x86_64-pc-windows-msvc.zip runner_os: Windows runner_arch: X64 syft_archive: syft_1.42.3_windows_amd64.zip syft_sha256: e1b9f4945aa64c2b34970bec617623d7f803d0661b48a50b966768b363322e2d - target: aarch64-pc-windows-msvc os: windows-11-vs2026-arm artifact: phantom-aarch64-pc-windows-msvc archive: phantom-aarch64-pc-windows-msvc.zip runner_os: Windows runner_arch: ARM64 syft_archive: syft_1.42.3_windows_arm64.zip syft_sha256: 76db35f9ec13628e8465685e9773e7de4f57efe1f05bb99959fdde59bdef5f6a steps: # Third-party actions pinned to commit SHAs — see ci.yml for rationale. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable (2026-04-24) with: toolchain: 1.95.0 targets: ${{ matrix.target }} - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 - name: Install cross-compilation tools if: matrix.target == 'aarch64-unknown-linux-gnu' run: | sudo apt-get update sudo apt-get install -y gcc-aarch64-linux-gnu - name: Build run: cargo build --release --locked --target ${{ matrix.target }} env: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc - name: Enforce GNU/Linux GLIBC 2.35 ceiling if: runner.os == 'Linux' run: | node scripts/release/check-glibc-baseline.mjs --baseline 2.35 \ target/${{ matrix.target }}/release/phantom \ target/${{ matrix.target }}/release/phantom-mcp - name: Package (Unix) if: runner.os != 'Windows' run: | cd target/${{ matrix.target }}/release tar czf ../../../${{ matrix.artifact }}.tar.gz phantom phantom-mcp cd ../../.. - name: Package (Windows) if: runner.os == 'Windows' shell: pwsh run: | $ErrorActionPreference = 'Stop' $PSNativeCommandUseErrorActionPreference = $true cd target/${{ matrix.target }}/release 7z a ../../../${{ matrix.artifact }}.zip phantom.exe phantom-mcp.exe cd ../../.. - name: Install checksum-verified Syft 1.42.3 shell: bash env: EXPECTED_RUNNER_OS: ${{ matrix.runner_os }} EXPECTED_RUNNER_ARCH: ${{ matrix.runner_arch }} SYFT_ARCHIVE: ${{ matrix.syft_archive }} SYFT_SHA256: ${{ matrix.syft_sha256 }} run: | set -euo pipefail if [ "$RUNNER_OS" != "$EXPECTED_RUNNER_OS" ] || [ "$RUNNER_ARCH" != "$EXPECTED_RUNNER_ARCH" ]; then echo "refusing Syft install on unexpected runner ${RUNNER_OS}/${RUNNER_ARCH}; expected ${EXPECTED_RUNNER_OS}/${EXPECTED_RUNNER_ARCH}" >&2 exit 1 fi install_dir="$PWD/.release-tools/syft" archive="$install_dir/$SYFT_ARCHIVE" mkdir -p "$install_dir" curl --proto '=https' --proto-redir '=https' --tlsv1.2 --fail --location --silent --show-error \ --max-redirs 3 --connect-timeout 10 --max-time 120 --max-filesize 134217728 \ --output "$archive" \ "https://github.com/anchore/syft/releases/download/v1.42.3/${SYFT_ARCHIVE}" actual=$(node -e 'const {createHash}=require("node:crypto");const {readFileSync}=require("node:fs");process.stdout.write(createHash("sha256").update(readFileSync(process.argv[1])).digest("hex"))' "$archive") if [ "$actual" != "$SYFT_SHA256" ]; then echo "Syft archive checksum mismatch: expected ${SYFT_SHA256}, got ${actual}" >&2 exit 1 fi case "$SYFT_ARCHIVE" in *.tar.gz) tar -xzf "$archive" -C "$install_dir" syft syft_bin="$install_dir/syft" ;; *.zip) 7z x "$archive" "-o${install_dir}" -y syft.exe >/dev/null syft_bin="$install_dir/syft.exe" ;; *) echo "unsupported Syft archive: ${SYFT_ARCHIVE}" >&2 exit 1 ;; esac "$syft_bin" version echo "SYFT_BIN=$syft_bin" >> "$GITHUB_ENV" - name: Generate SPDX 2.3 SBOM for the exact archive shell: bash run: '"$SYFT_BIN" "${{ matrix.archive }}" -o "spdx-json=${{ matrix.archive }}.spdx.json"' - name: Upload artifact uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: ${{ matrix.artifact }} path: | ${{ matrix.archive }} ${{ matrix.archive }}.spdx.json if-no-files-found: error native-acceptance: name: Native acceptance (${{ matrix.target }}) needs: build runs-on: ${{ matrix.os }} permissions: contents: read strategy: fail-fast: false matrix: include: - target: x86_64-apple-darwin os: macos-15-intel artifact: phantom-x86_64-apple-darwin archive: phantom-x86_64-apple-darwin.tar.gz runner_os: macOS runner_arch: X64 - target: aarch64-apple-darwin os: macos-15 artifact: phantom-aarch64-apple-darwin archive: phantom-aarch64-apple-darwin.tar.gz runner_os: macOS runner_arch: ARM64 - target: x86_64-unknown-linux-gnu os: ubuntu-22.04 artifact: phantom-x86_64-unknown-linux-gnu archive: phantom-x86_64-unknown-linux-gnu.tar.gz runner_os: Linux runner_arch: X64 - target: aarch64-unknown-linux-gnu os: ubuntu-22.04-arm artifact: phantom-aarch64-unknown-linux-gnu archive: phantom-aarch64-unknown-linux-gnu.tar.gz runner_os: Linux runner_arch: ARM64 - target: x86_64-pc-windows-msvc os: windows-latest artifact: phantom-x86_64-pc-windows-msvc archive: phantom-x86_64-pc-windows-msvc.zip runner_os: Windows runner_arch: X64 - target: aarch64-pc-windows-msvc os: windows-11-vs2026-arm artifact: phantom-aarch64-pc-windows-msvc archive: phantom-aarch64-pc-windows-msvc.zip runner_os: Windows runner_arch: ARM64 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: name: ${{ matrix.artifact }} path: native-artifact - name: Verify and execute the exact archive on its native runner env: PHANTOM_NATIVE_ARCHIVE: native-artifact/${{ matrix.archive }} PHANTOM_NATIVE_TARGET: ${{ matrix.target }} PHANTOM_RELEASE_TAG: ${{ inputs.release_tag }} run: node scripts/release/native-release-smoke.mjs - name: Install the exact archive and prove transaction rollback env: PHANTOM_NATIVE_ARCHIVE: native-artifact/${{ matrix.archive }} PHANTOM_NATIVE_TARGET: ${{ matrix.target }} PHANTOM_RELEASE_TAG: ${{ inputs.release_tag }} run: node scripts/release/native-installer-acceptance.mjs - name: Test primary npm wrapper platform mapping run: node npm/test/platform-matrix.test.js - name: Test primary npm wrapper version cache run: node npm/test/version-cache.test.js - name: Test primary npm wrapper valid cache run: node npm/test/valid-cache.test.js - name: Test primary npm wrapper hardening run: node npm/test/hardening.test.js - name: Test MCP npm wrapper platform mapping run: node npm-mcp/test/platform-matrix.test.js - name: Test MCP npm wrapper version cache run: node npm-mcp/test/version-cache.test.js - name: Test MCP npm wrapper valid cache run: node npm-mcp/test/valid-cache.test.js - name: Test MCP npm wrapper hardening run: node npm-mcp/test/hardening.test.js - name: Test MCP schema contract run: node npm-mcp/test/schema-contract.test.js - name: Install and execute the exact archive through both npm wrappers env: PHANTOM_NATIVE_ARCHIVE: native-artifact/${{ matrix.archive }} PHANTOM_NATIVE_TARGET: ${{ matrix.target }} PHANTOM_RELEASE_TAG: ${{ inputs.release_tag }} run: node scripts/release/npm-wrapper-native-acceptance.mjs verify-artifacts: name: Verify checksums, artifacts, and SBOMs needs: [build, native-acceptance] runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: path: artifacts - name: Generate SHA-256 checksums working-directory: artifacts run: | set -euo pipefail : > ../SHA256SUMS while IFS= read -r -d '' f; do base=$(basename "$f") dir=$(dirname "$f") (cd "$dir" && sha256sum "$base") | tee "$f.sha256" >> ../SHA256SUMS done < <(find . -type f \( -name '*.tar.gz' -o -name '*.zip' \) -print0 | sort -z) mv ../SHA256SUMS ./SHA256SUMS - name: Verify exact release artifact and SBOM set run: node scripts/release/verify-release-artifacts.mjs artifacts - name: Preserve the verified release bundle uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: verified-release-bundle path: artifacts if-no-files-found: error