Skip to content

ci: mirror every release to GitHub Packages as well as npm - #5

Merged
HaydenBruin merged 1 commit into
mainfrom
ci/dual-publish
Aug 25, 2026
Merged

ci: mirror every release to GitHub Packages as well as npm#5
HaydenBruin merged 1 commit into
mainfrom
ci/dual-publish

Conversation

@HaydenBruin

Copy link
Copy Markdown
Contributor

Publishes each release to both registries: npmjs first (canonical), then a
mirror to GitHub Packages.

  • npm publish --registry=https://npm.pkg.github.com after semantic-release, so
    package.json stays pinned to npmjs and the second target is a CLI override
  • Authenticates with GITHUB_TOKEN — GitHub Packages accepts it for a same-repo
    publish, so no new secret
  • Self-skips when nothing was released, by checking whether semantic-release
    replaced the 0.0.0-development placeholder. A docs-only push no-ops rather
    than failing

What this does not buy

GitHub Packages still requires an access token to install, even for public
packages — that is a GitHub restriction on reads, not on publishing. So the
mirror is for the org-internal listing and for anything still pointed there; it
is not a way to consume the package without credentials. Both consumer repos
resolve from npm.

If the two registries ever disagree, npm is canonical.

Current state

GitHub Packages holds 0.2.0, 0.2.1, 0.3.0 from before the move to npm and
has had nothing since. From 0.4.0 onward the two stay in step.

Both registries now get every version. npm is canonical — it is what the
consumer repos install from and the only one that needs no credential — and
GitHub Packages receives a mirror of the same version immediately after.

The mirror is a plain `npm publish --registry=https://npm.pkg.github.com` after
semantic-release, so package.json stays pinned to npmjs and the second target is
a command-line override. It authenticates with GITHUB_TOKEN, which GitHub
Packages accepts for a same-repo publish, so no additional secret exists.

It self-skips when nothing was released. semantic-release's npm plugin writes
the real version into package.json in the workspace during prepare, so a version
other than the 0.0.0-development placeholder is the signal that a release
happened. A docs-only push leaves the placeholder and the step no-ops rather
than failing.

Worth being clear about what this does not buy: GitHub Packages still cannot be
installed from without an access token, because that is a GitHub restriction on
reads rather than on publishing. The mirror is for the org-internal package
listing and for anything still pointed there — it is not a way to consume the
package without credentials. If the two registries ever disagree, npm is right.

GitHub Packages currently holds 0.2.0, 0.2.1 and 0.3.0 from before the move to
npm, and has received nothing since; from 0.4.0 onward the two stay in step.
@HaydenBruin
HaydenBruin merged commit c8c55b0 into main Aug 25, 2026
1 check 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.

1 participant