Skip to content

ci(release): build npm packages without credentials and publish from a protected job - #814

Open
nik13 wants to merge 1 commit into
devfrom
ci/release-pipeline-hardening
Open

nik13 wants to merge 1 commit into
devfrom
ci/release-pipeline-hardening

Conversation

@nik13

@nik13 nik13 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

  1. Separates TypeScript package builds from npm publishing. release-typescript.yml runs with contents: read, persist-credentials: false, and no publishing secrets; it installs dependencies with --frozen-lockfile --ignore-scripts, stages tarballs, runs the clean-install smoke check, and uploads the npm-packages artifact only when steps.verify.outputs.verified == 'true'. A separate top-level typescript job in release.yml runs in the protected npm-publish environment, depends on typescript-build succeeding with verified == 'true', holds NPM_TOKEN and id-token: write, downloads those exact verified tarballs, and publishes them in dependency order with provenance.
  2. Prevents cross-ecosystem ambiguity in --only selection and tags. .github/release/release_plan.py refuses an ambiguous plain --only NAME when that name exists in more than one ecosystem (exit 2 with a hint to pass ECOSYSTEM:NAME), accepts ECOSYSTEM:NAME selection, and checks in --check that every release tag is unique across ecosystems.
  3. Verifies built Ruby gems before uploading them. ruby-build installs the built .gem into a clean GEM_HOME with --local --ignore-dependencies --no-document, checks its name, version, and packaged file list against the built gem specification without loading agent code, and uploads the artifact only when steps.verify.outputs.verified == 'true'.
  4. Sets 1-day artifact retention across release and test workflows. Every actions/upload-artifact step across the release and test workflows sets retention-days: 1.
  5. Updates RELEASING.md with the npm-publish environment setup and approval step, 1-day artifact retention guidance, ecosystem:name selection, and the Ruby pre-upload verification step.

Why?

The Python, NuGet, and Ruby release pipelines already separated credential-free builds from protected publish jobs, while TypeScript built and published inside a single job with secrets: inherit. In addition, --only matched package names without ecosystem qualification, Ruby uploaded gems before checking the built artifact, and workflow artifacts kept the default 90-day retention.

How was it tested?

  • unittest discover .github/release: 149 passed, 0 failed, 1 skipped (including new test_a_selected_name_publishes_to_one_ecosystem_only, which fails before this change and passes after).

  • .github/scripts test suite: 65 passed, 0 failed.

  • test_release_strategies.cjs (offline release-please strategy check): 1 passed, 0 failed.

  • python3 .github/release/release_plan.py --check, bootstrap_audit.py --check, and release_plan.py --offline: exit 0.

  • actionlint (with shellcheck): 0 new findings.

  • Static YAML policy check across workflows: verifies credential isolation, protected environment, retention-days: 1 on all 21 upload-artifact steps, and publish dependency on verified build outputs.

  • Clean-container checks for Ruby gem verification (valid gems pass; wrong-version and missing-file controls fail) and TypeScript stage + verify + tarball layout round-trip without credentials.

  • Unit tests added / updated (unittest)

  • Workflow lint (actionlint) passes with 0 new findings

  • Release documentation updated (RELEASING.md)

Checklist

  • Commit messages follow Conventional Commits
  • No TODOs or commented-out code left in
  • No real API keys or secrets in the diff
  • If prose was added or changed: checked against docs/VOCABULARY.md

Notes for reviewers

Targets dev.

Required before merge

  • Create the npm-publish GitHub environment with required reviewers and deployment branches restricted to main (otherwise GitHub creates an unprotected environment on first run).
  • Set npm trusted publishers to use environment npm-publish.