Skip to content

ci: publish to npm automatically from CI - #1225

Merged
Naturalclar merged 3 commits into
masterfrom
claude/init-yfdkki
Nov 15, 2026
Merged

Naturalclar merged 3 commits into
masterfrom
claude/init-yfdkki

Conversation

@Naturalclar

Copy link
Copy Markdown
Member

Overview

Implements #1223. Releases move from a manual local operation to a CI workflow.

Today a release means a maintainer running yarn release with npm credentials on hand. Every published release is authored by one person, and master currently carries four releasable commits since v2.0.0 that have never reached npm — feat(ios): preferredElementSize (#1202) plus three fix: commits.

The release tooling itself was already configured; only the automation was missing. This PR does not change how versions or changelogs are produced.

.github/workflows/release.yml

Triggers on the Build workflow completing on master and runs the existing release-it configuration if Build passed. Using workflow_run means the gate is exact — lint, tsc, android, and both iOS builds must be green before anything is published — and it builds on the push trigger fixed in #1224.

Version and release notes still come from @release-it/conventional-changelog, so the output matches the current manual release. The bump is decided entirely by commit messages: fix:/perf: → patch, feat: → minor, ! or a BREAKING CHANGE: footer → major.

Two guards:

  • Unvalidated commits are never published. If master has moved past the commit Build validated, the run skips instead of shipping code CI never checked. The next green Build picks it up.
  • A release cannot trigger another release. The chore: release <version> commit that release-it pushes is ignored.

A push whose commits are all chore/docs/test/refactor stops before touching npm, since the angular preset would produce no bump.

Authentication uses an NPM_TOKEN repository secret, read through the .npmrc that actions/setup-node writes. GITHUB_TOKEN with contents: write covers the release commit, tag, and GitHub release.

Release can also be dispatched manually for a release that failed partway through. That path skips the Build gate by design and is documented as such.

Gradle heap bump

Separate commit, and a prerequisite rather than an unrelated drive-by. The android job fails intermittently — roughly half of recent runs — during dependency resolution:

Failed to transform react-android-0.81.1-debug.aar
  > Execution failed for JetifyTransform: .../react-android-0.81.1-debug.aar
     > Java heap space

It failed on #1222's first attempt and on the master push run after #1224 merged, and passed on #1222's re-run and on #1224. Since publishing is gated on a green Build, a job that fails half the time blocks releases half the time. -Xmx2g is no longer enough for the Jetifier transform; ubuntu runners have ample memory.

Before the first release

An npm access token with publish rights on @react-native-menu/menu must be added as an NPM_TOKEN repository secret. Without it the workflow runs and fails at the publish step.

Two things worth checking:

  • Branch protection. release-it pushes the release commit and tag directly to master. If master requires pull requests or status checks for pushes, GITHUB_TOKEN will be rejected and the release will fail after publishing to npm, leaving npm and git out of sync.
  • Commit messages are now load-bearing. With release-on-merge, a feat mislabelled as chore silently ships nothing. CONTRIBUTING.md states that pre-commit hooks verify the format, but no husky, lefthook, or commitlint configuration exists in the repo — so squash-merge titles are what actually decide the version. This is documented rather than enforced; wiring up commitlint would be a separate change.

Test Plan

A workflow_run trigger only fires from the workflow file on the default branch, so this workflow cannot execute before merge. The first merge to master is the real test. What was verified instead:

  • The release guard was run against real history, not eyeballed. On the current master it resolves git describe --tags --abbrev=0 to v2.0.0, walks v2.0.0..HEAD, and finds exactly 4 releasable commits — the 1 feat and 3 fix listed above — which is a minor bump. Re-running it after a release would find 0 and skip.
  • The guard's regex requires colon-space, matching conventional-changelog's own header parser, so the guard and release-it agree on what counts as releasable. (Note this means a historical subject like fix:lint error would be skipped by both, consistently.)
  • release.yml was parsed as YAML to confirm it is well formed.
  • The Jetifier OOM was read from the failing job logs of run 31983633654 (the master push run) and cross-checked against the same failure on docs: add CLAUDE.md with build commands and architecture overview #1222, confirming it happens in :app:checkDebugAarMetadata during dependency transform, before any project code compiles.
  • yarn lint could not be run — dependencies are not installed in this environment. Biome 1.9.4 covers JS/TS/JSON, and this diff is YAML, Markdown, and a .properties file, so it is outside Biome's scope regardless. The lint job on this PR confirms it.

The android job on this PR is the first check of the heap bump; if it passes here and on subsequent runs, the OOM is addressed.


Generated by Claude Code

The android job fails intermittently — roughly half of recent runs — while
Jetifier rewrites react-android-0.81.1-debug.aar:

    Failed to transform react-android-0.81.1-debug.aar
      > Execution failed for JetifyTransform: .../react-android-0.81.1-debug.aar
         > Java heap space

The failure happens during dependency resolution, before any project code is
compiled, and is unrelated to whatever change is under test. 2g is no longer
enough for the transform; ubuntu runners have ample memory.

This matters beyond the flake itself: publishing is gated on a green Build, so
an intermittently red android job intermittently blocks releases.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GWYKHSVSNoLM8Hquum8CuD
Releases were a manual, local operation: a maintainer ran `yarn release` with
npm credentials on hand. Every published release is authored by one person, and
master has carried four releasable commits since v2.0.0 without them reaching
npm.

Add a Release workflow that runs the existing release-it configuration in CI.
It triggers on the Build workflow completing on master and releases only if
Build passed, so publishing is gated on lint, tsc, and the Android/iOS builds.
Version and changelog still come from @release-it/conventional-changelog, so
output matches the current manual release.

Two guards keep it honest:

- If master has moved past the commit Build validated, the run skips rather
  than publishing code CI never checked. The next green Build picks it up.
- The `chore: release` commit release-it pushes is ignored, so a release
  cannot trigger another release.

A run whose commits are all chore/docs/test/refactor stops before touching npm,
since the angular preset would produce no version bump.

Authentication uses an NPM_TOKEN repository secret, read via the .npmrc that
actions/setup-node writes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GWYKHSVSNoLM8Hquum8CuD
CONTRIBUTING.md documented `!` after the type as producing a major
release, but the configured `angular` preset does not parse `!` at all.
Its header pattern is /^(\w*)(?:\((.*)\))?: (.*)$/ with no
breakingHeaderPattern, and whatBump only escalates to major when a
commit has notes, which only a `BREAKING CHANGE:` footer produces.

Checked against the installed presets:

    angular              conventionalcommits
    PATCH (type=undef)   MAJOR   feat!: drop iOS 13 support
    PATCH (type=undef)   MAJOR   refactor!: remove MenuView.foo
    PATCH                MAJOR   refactor: tidy + BREAKING-CHANGE: footer
    MAJOR                MAJOR   feat: x + BREAKING CHANGE: footer

So a maintainer following the docs to remove a public API would have
shipped it as a patch. Note `feat!:` does not even register as a
feature under angular, so it was a patch rather than a minor.

Switch the preset to `conventionalcommits`, which supports `!` on any
type and accepts both the spaced and hyphenated footer. It is already a
direct dependency of @release-it/conventional-changelog alongside the
angular preset, so this needs no dependency change.

Also in the release guard:

- Widen the releasable-commit test to match the preset: `!` on any type
  counts, not just feat/fix/perf, so a `refactor!:` breaking change no
  longer skips the release entirely.
- Check the subject and the body against separate patterns. Matching one
  pattern against the whole message let a body line that merely starts
  with "fix: " count as a fix, which a `docs:` commit with a prose body
  could trigger.
- Read commits from a file rather than a pipe, so a failing `git log`
  fails the step instead of silently counting zero and skipping.
- Require `workflow_run.event == 'push'`. The `branches: master` filter
  matches the triggering run's head branch, and Build also runs on
  pull_request, so a fork PR from a branch named "master" satisfied it.
  The head_sha guard already stopped that from publishing, but this
  states the intent rather than relying on the backstop.
- Bump checkout and setup-node to v5, matching the Build workflow.

Verified the guard against a synthetic history covering 16 message
shapes, and against real history since v2.0.0: it finds the same 4
releasable commits that conventional-recommended-bump does, which
recommends `minor` from feat(ios): preferredElementSize.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Naturalclar

Copy link
Copy Markdown
Member Author

Review

Rebased onto master (which now carries #1234) and pushed fixes for the findings below. All five checks were green on the rebased head before the fix commit.

1. The documented versioning rule was wrong — fixed in 5e79cf6

CONTRIBUTING.md said:

! after the type, or a BREAKING CHANGE: footer → major

But package.json configured the angular preset, which does not parse ! at all. Its header pattern is /^(\w*)(?:\((.*)\))?: (.*)$/ — no breakingHeaderPattern — and whatBump only escalates to major when a commit has notes, which only a BREAKING CHANGE: footer produces.

Run against the two installed presets:

commit angular conventionalcommits
feat!: drop iOS 13 support PATCH (type=undefined) MAJOR
refactor!: remove MenuView.foo PATCH (type=undefined) MAJOR
refactor: tidy + BREAKING-CHANGE: footer PATCH MAJOR
feat: x + BREAKING CHANGE: footer MAJOR MAJOR

So a maintainer following the docs to remove a public API would have shipped it as a patch. Note feat!: didn't even register as a feature, so it was a patch rather than a minor. This was live risk: the history has never used ! or a BREAKING CHANGE: footer, so the first person to trust the doc would have been the one bitten.

Switched the preset to conventionalcommits. It's already a direct dependency of @release-it/conventional-changelog alongside the angular preset, so no dependency change was needed.

2. Guard fixes — also in 5e79cf6

  • Widened the releasable test to match the preset: ! on any type now counts. Previously refactor!: / chore!: scored zero and skipped the release entirely, so a breaking change shipped nothing.
  • Subject and body are now checked separately. One pattern against the whole message let a body line that merely starts with fix: count as a fix — a docs: commit with prose could trigger a release. (My first attempt at this, counting commits instead of lines, did not fix it; the test caught that.)
  • Commits read from a file, not a pipe, so a failing git log fails the step instead of silently counting zero and skipping the release.
  • grep -c → explicit count. The old count was lines, not commits, so the "Releasable commits since …: N" log line was misleading.
  • Added workflow_run.event == 'push' to the job if. branches: master matches the triggering run's head branch, and Build also runs on pull_request — so a fork PR from a branch named master satisfied the filter and started this job. The head_sha guard already stopped it from publishing and NODE_AUTH_TOKEN only exists on the skipped step, so nothing leaked, but that was defense by accident.
  • checkout/setup-node v4 → v5, matching the Build workflow after ci: fix yarn cache and replace deprecated actions #1234.

Verified against a synthetic history covering 16 message shapes (all pass), and against real history since v2.0.0: the guard finds the same 4 releasable commits that conventional-recommended-bump does, which recommends minor from feat(ios): preferredElementSize.

3. Still needed before merge: NPM_TOKEN

gh secret list is empty — no repository secrets are configured, so publishing cannot work yet.

The good news: release-it's npm plugin validates auth in init() (lib/plugin/npm/npm.js:43,53), which runs for all plugins before the bump/release hooks. So a missing token fails fast with no side effects — no version bump, no commit, no tag, no GitHub release, no partial publish. Just a red workflow. But it does need setting.

4. Suggest splitting the Gradle commit out

48f947b ci: raise Gradle heap to 4g to stop Jetifier OOM is unrelated to npm publishing, and it's plausibly the fix for the intermittent android failure on master. It shouldn't sit behind review of the release automation — worth cherry-picking into its own PR and merging now.

For the record, that commit's body does carry the error text (JetifyTransform … > Java heap space), so the claim isn't baseless — but it's no longer independently verifiable, since the August run's logs have expired. 4g is low-risk regardless on a 16GB runner.

Not changed

  • Publishing is gated on lint/tsc/compile, not tests — Build never runs yarn test. Consistent with the repo (jest is a placeholder per CLAUDE.md), just worth knowing.
  • The sha guard, the chore: release self-trigger exclusion, and the concurrency group are all the right instincts and were left as-is.

@Naturalclar
Naturalclar merged commit d9b13f1 into master Nov 15, 2026
5 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