Skip to content

ci: gated release pipeline (npm Trusted Publishing + GitHub Release) - #5

Open
alexanderolvera wants to merge 2 commits into
mainfrom
feat/release-pipeline
Open

ci: gated release pipeline (npm Trusted Publishing + GitHub Release)#5
alexanderolvera wants to merge 2 commits into
mainfrom
feat/release-pipeline

Conversation

@alexanderolvera

Copy link
Copy Markdown
Owner

What

Adds .github/workflows/release.yml — a tag-triggered release pipeline that publishes to npm and cuts a matching GitHub Release, with an Azure-DevOps-style manual approval gate before publish.

How you cut a release

npm version <patch|minor|major>   # bumps package.json, commits, tags vX.Y.Z
git push --follow-tags

The v* tag push triggers the workflow.

Flow

Job 1 — verify (no special perms):

  • Tag must equal package.json version (fails otherwise).
  • Refuse to republish a version already on npm.
  • npm ci → build → typecheck → lint → test.
  • npm pack → upload the tarball as an artifact (built once, promoted).

Job 2 — publish (needs: verify, environment: npm-production):

  • Pauses at the approval gate until a required reviewer clicks approve.
  • Publishes the same tarball via npm Trusted Publishing (OIDC, id-token: write) — no stored NPM_TOKEN — with a provenance attestation.
  • Creates the GitHub Release, notes pulled from the matching CHANGELOG.md section (regex-free extraction; autogenerated notes as fallback).

One-time setup (required before the first tag)

  1. Approval gate — Settings → Environments → new environment npm-production → enable Required reviewers, add yourself.
  2. npm Trusted Publishing — npmjs.com → the package → Settings → Trusted Publishing → add publisher: repo alexanderolvera/dfhack-remote-node, workflow release.yml, environment npm-production.

Provenance requires the repo to stay public (it is).

GitHub vs Azure DevOps note

GitHub has no separate "Releases pipeline" entity — this is a normal workflow. The ADO release-approval gate maps to a protected Environment with required reviewers; artifact promotion maps to upload-artifactdownload-artifact across jobs.

🤖 Generated with Claude Code

Tag-triggered release workflow. Pushing a vX.Y.Z tag runs a verify job
(tag/version match, refuse-republish guard, build, typecheck, lint, test,
pack) then a publish job gated behind a protected `npm-production`
Environment. Publish uses npm Trusted Publishing (OIDC, provenance) with no
stored token, promotes the tarball built in verify, and creates a matching
GitHub Release with notes extracted from CHANGELOG.md.

Changelog extraction is literal-substring (regex-free) so it behaves the
same across awk flavors and won't pull in the trailing link-reference block.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 17, 2026 02:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a tag-triggered GitHub Actions release workflow for this npm package, building and verifying once, then using a protected Environment as a manual approval gate before publishing via npm Trusted Publishing (OIDC + provenance) and creating a matching GitHub Release.

Changes:

  • Introduces a verify job that validates tag/version alignment, checks npm for an existing version, runs CI steps, and uploads a single built tarball artifact.
  • Introduces a gated publish job (environment: npm-production) that downloads the promoted tarball, publishes to npm with provenance, and creates a GitHub Release with notes extracted from CHANGELOG.md (or autogenerated as fallback).

Comment on lines +41 to +43
verify:
runs-on: ubuntu-latest
steps:
Comment on lines +90 to +92
permissions:
contents: write # create the GitHub Release
id-token: write # OIDC for npm Trusted Publishing + provenance
Comment on lines +111 to +114
set -euo pipefail
tgz=$(ls release-artifact/*.tgz)
echo "Publishing $tgz"
npm publish "$tgz" --provenance --access public
Comment thread .github/workflows/release.yml Outdated
flag && substr($0, 1, 1) == "[" { exit }
flag { print }
' CHANGELOG.md)
tgz=$(ls release-artifact/*.tgz)
Comment on lines +101 to +103
- name: Use an npm new enough for OIDC trusted publishing
run: npm install -g npm@latest

Copilot AI review requested due to automatic review settings July 17, 2026 03:03
@alexanderolvera
alexanderolvera removed the request for review from Copilot July 17, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants