Skip to content

ci: create the GitHub release when publishing to npm - #474

Merged
TimelordUK merged 1 commit into
masterfrom
ci/github-release-on-publish
Oct 11, 2026
Merged

TimelordUK merged 1 commit into
masterfrom
ci/github-release-on-publish

Conversation

@TimelordUK

Copy link
Copy Markdown
Owner

Publishing to npm and releasing on GitHub now happen in one step: a real run of NPM Package Validation and Publish also creates the GitHub release.

What it does

  • A new github-release job runs after a successful (non dry run) publish:
    • tags vX.Y.Z on the published commit
    • creates Release vX.Y.Z from .github/RELEASE_TEMPLATE.md
    • attaches the npm tarball
    • marks it latest when published to npm latest, otherwise pre-release
  • It's a separate job, so if it fails after npm has published, "Re-run failed jobs" retries only the release. If the release already exists, it updates it rather than failing.
  • Every run, dry or real, writes the rendered notes to the job summary, so a dry run is also a preview.
  • New optional input upgrading fills the Upgrading section. Left empty, the section is dropped.

How the notes are built

.github/scripts/release-notes.js (no dependencies):

  • keeps the template's standing content below its --- line and strips the EDIT ME comments
  • fills "What's changed" from the squash-merged PR titles since the previous v* tag, grouped as Features / Fixes / Performance / Other, with each PR linked
  • leaves out chore, ci, test, docs, refactor and dependabot bumps

Preview locally:

node .github/scripts/release-notes.js --version 5.6.0

Testing

  • Rendered locally against the real tags (since v5.5.1 and since v5.4.0), with and without --upgrading.
  • eslint is clean, and the workflow YAML parses.
  • The github-release job itself first runs on the next real publish. Do a dry run first to check the preview.

🤖 Generated with Claude Code

The publish workflow now creates "Release vX.Y.Z" after a successful npm
publish: it tags the published commit, builds the notes from
.github/RELEASE_TEMPLATE.md and attaches the npm tarball.

.github/scripts/release-notes.js keeps the template's standing content and
fills "What's changed" from the PR titles merged since the previous v* tag,
grouped by feat / fix / perf, leaving out chore, ci, test, docs and
dependency bumps. "Upgrading" comes from a new optional workflow input and
is dropped when empty. A dry run shows the notes in the job summary as a
preview. The release is its own job, so a failure after npm has published
can be retried on its own, and it updates an existing release instead of
failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
body = body.replace(/## Upgrading\s*\n[\s\S]*?(?=^---\s*$)/m,
upgrading ? `## Upgrading\n\n${upgrading}\n\n` : '')
// any remaining EDIT ME comments are for the person editing, not the reader
body = body.replace(/<!--[\s\S]*?-->\s*\n?/g, '')
@TimelordUK
TimelordUK merged commit 25e6a76 into master Oct 11, 2026
10 of 11 checks passed
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.

2 participants