Skip to content

feat: add npm-is-release action - #27

Merged
rekmarks-consensys-1 merged 17 commits into
mainfrom
ocap/npm-is-release
Nov 30, 2026
Merged

rekmarks-consensys-1 merged 17 commits into
mainfrom
ocap/npm-is-release

Conversation

@rekmarks-consensys-1

@rekmarks-consensys-1 rekmarks-consensys-1 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Lines added, by type

Code Tests Docs Lockfiles Config Total
237 (31%) 423 (55%) 113 0 1 774

Adds npm-is-release, a port of MetaMask/action-is-release v2 (3cd51b9). On a push, it reports IS_RELEASE=true when two things hold: the root package.json version changed since before, and the commit message starts with one of the commit-starts-with prefixes, if any are given.

To review: the first commit is a verbatim copy of upstream's action.yml, scripts/is-release.sh and README.md at 3cd51b9, so reviewing commit by commit shows each change against upstream.

Upstream's inputs and the IS_RELEASE output are kept, and the one new input has a default, so callers only change their uses: line. Upstream is MIT-licensed; NOTICE carries its copyright and permission notice, and the README links to it.

Differences from upstream

  • Bug fix: prefixes are matched literally. Upstream matched them as regular expressions, so Release [version] with version 1.2.0 also matched Release 1x2y0, and characters like ( broke the match.
  • Prefixes may also be separated by newlines (a YAML block scalar). Whitespace around each one is trimmed, and empty ones are ignored; upstream's empty prefix matched every commit.
  • The checkout uses persist-credentials: false. A new github-token input (default: the job token) is passed only to the git fetch of before, as an Authorization header through GIT_CONFIG_* environment variables appended after any already set, so it is never in argv or .git/config, and it is left out of the RUNNER_DEBUG trace. This lets a multi-commit push in a private repository fetch before.
  • before is fetched only when it is missing, and without its ancestors in a shallow clone. On a single-commit push it is HEAD^, already in the fetch-depth: 2 checkout, so there is no network call and the token isn't used. Otherwise it is fetched with --depth=1 in a shallow clone; a full clone (from skip-checkout) is fetched into without --depth, so it isn't made shallow. A failed fetch is an error. Upstream always fetched before with all its ancestors, which on a multi-commit push meant the repository's whole history. (Suggested by Joshua Fernandes in review.)
  • before must be a full commit SHA (40 or 64 hexadecimal characters). Upstream passed any value to git fetch and git show, where one starting with - is read as an option: --upload-pack=<command> ran the command against a local origin.
  • Both versions must be valid semver, or the action fails. Upstream compared any values, including a missing version. The versions are printed and substituted into the prefixes, so a version containing a newline followed by :: was printed as a workflow command.
  • The new version is read from the committed package.json at HEAD (git show HEAD:package.json). Upstream read the working tree, so with skip-checkout an uncommitted version bump counted as a release.

Known limitation, kept from upstream: a push that creates a branch has an all-zero before, with no commit to compare with, so the action fails (now with its own error rather than a failed fetch). ocap-kernel only calls it on pushes to main.

Tests

  • test/fixtures.sh builds fixture repositories with local origins and clones them with --depth 2, as actions/checkout with fetch-depth: 2 would. It covers:
    • an unchanged version;
    • each of ocap-kernel's prefixes;
    • a non-matching subject;
    • the regex regression;
    • no prefixes at all;
    • commit-message overriding the HEAD subject;
    • a multi-commit push, where before is outside the clone and has to be fetched;
    • when and how before is fetched: already present (no fetch, token unused), missing from a shallow clone (only that commit fetched, clone stays shallow), missing from a full clone (not made shallow), and a failed fetch;
    • with a token, that the fetch gets the Authorization header after a reset of the same key, that existing GIT_CONFIG_* entries are kept, and that the debug trace leaves out the token;
    • empty and all-zero before, an abbreviated SHA, a ref, an upper-case SHA, a 64-character SHA in a SHA-256 repository, and a before that is a git option, which must run no command;
    • spaces after commas, newline-separated prefixes, and empty prefixes;
    • a pre-release version with build metadata;
    • versions that aren't semver, are missing, or contain a newline and a workflow command;
    • an uncommitted version change in the working tree.
  • The workflow also runs the action with skip-checkout: true.
  • Run against upstream's script, the fixtures give the same results except on the cases covering the differences: the three literal-matching cases (including the pre-release version, whose + upstream read as a quantifier), the three prefix-list cases, the two checks of the token passed to the fetch, the check that a before starting with - runs no command, the four invalid version cases, the uncommitted-change case, and three of the new fetch checks.

🤖 Generated with Claude Code

@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/check-changelog branch 2 times, most recently from bc6381b to b31c471 Compare November 23, 2026 23:26
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/npm-is-release branch 2 times, most recently from 09de74b to d4d3b39 Compare November 24, 2026 19:36
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/check-changelog branch 2 times, most recently from 1f7749e to deea498 Compare November 24, 2026 19:54
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/npm-is-release branch 2 times, most recently from 5144c62 to 5f381c2 Compare November 24, 2026 20:28
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/check-changelog branch 2 times, most recently from 490ac84 to 92c4437 Compare November 24, 2026 20:58
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/npm-is-release branch 2 times, most recently from 90d7df6 to 5a9860e Compare November 24, 2026 21:24
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/check-changelog branch 2 times, most recently from 0f5a1f7 to d6a5bf0 Compare November 24, 2026 21:39
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/npm-is-release branch 2 times, most recently from 59a3b46 to 5ee0017 Compare November 24, 2026 22:37
@rekmarks-consensys-1
rekmarks-consensys-1 force-pushed the ocap/npm-is-release branch 2 times, most recently from c522e41 to 0103900 Compare November 25, 2026 00:16
@rekmarks-consensys-1
rekmarks-consensys-1 marked this pull request as ready for review November 25, 2026 00:30
@rekmarks-consensys-1
rekmarks-consensys-1 requested review from a team as code owners November 25, 2026 00:30
@rekmarks-consensys-1
rekmarks-consensys-1 removed this pull request from stack #30 November 25, 2026 01:05
@rekmarks-consensys-1
rekmarks-consensys-1 changed the base branch from ocap/check-changelog to ocap/check-changelog-bundle November 25, 2026 01:05
rekmarks-consensys-1 and others added 17 commits November 30, 2026 09:52
Verbatim copy of MetaMask/action-is-release, as the baseline for the
port's changes:

- action.yml -> npm-is-release/action.yml
- scripts/is-release.sh -> npm-is-release/scripts/is-release.sh
- README.md -> npm-is-release/README.md

Upstream: https://github.com/MetaMask/action-is-release
SHA: 3cd51b98fa98d1347d06f5961299b0172ee31ae8

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No change in behaviour:

- action.yml: SPDX header, actions/checkout pinned to a commit SHA,
  named steps, shorter input descriptions, explicit empty default for
  commit-starts-with, and the action path passed through env rather
  than interpolated into `run`.
- is-release.sh: SPDX header and usage comment, `set -u` with
  defaults for the optional variables, `::error::` annotation for a
  missing BEFORE, quiet fetch, lowercase locals, a set_output helper,
  and clearer log messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream tested `[[ $COMMIT_MESSAGE =~ ^$prefix ]]`, so each prefix was a
regular expression: with version 1.2.0, `Release [version]` also matched
`Release 1x2y0`, and characters such as `(` changed or broke the match.
Compare with a quoted glob prefix instead.

The `[version]` replacement is quoted too, so a `&` in the version is
not expanded under bash 5.2's patsub_replacement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p empty ones

commit-starts-with may now also be split across lines (a YAML block
scalar), whitespace around each prefix is trimmed, and empty prefixes
are skipped. Upstream kept the spaces in `a, b`, so the second prefix
started with a space, and an empty prefix (e.g. from a trailing comma)
matched every commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The checkout no longer leaves the token in the git config, so later
steps in the caller's job cannot reuse it.

Without credentials, fetching `before` fails in a private repository.
For a single-commit push `before` is HEAD^, already present with
fetch-depth 2, so the script now continues with a warning when the fetch
fails but the commit is present, and fails only when it is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test/fixtures.sh builds fixture repositories with local bare origins,
clones them with --depth 2 (as actions/checkout with fetch-depth 2
does) and runs the script. It covers an unchanged version, each of
ocap-kernel's release prefixes, a non-matching subject, the regex
regression (`Release 1x2y0`), regex metacharacters in a prefix, spaced,
newline-separated and empty prefixes, no prefixes, commit-message
overriding the HEAD subject, a multi-commit push whose `before` must be
fetched, and empty and all-zero `before`.

The workflow runs the fixtures and runs the action itself with
skip-checkout in a workspace prepared by `fixtures.sh
--prepare-workspace`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Describe the port: provenance and differences from upstream, usage with
a pinned SHA, inputs and outputs tables, behaviour (including the
fetch fallback and the all-zero `before` limitation kept from
upstream), and how the tests run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README said upstream's script fails only the two literal-matching
fixtures; run against it, the fixtures also differ on spaced,
newline-separated and empty prefixes (five cases in all). The script's
usage comment still described COMMIT_STARTS_WITH as comma-separated
only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script is ported from MetaMask/action-is-release, which is MIT-licensed. NOTICE carries its copyright and permission notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The checkout doesn't persist credentials, so in a private repository a push of more than one commit couldn't fetch before and the action failed. A new github-token input (default: the job token) is passed to that one git fetch as an Authorization header through GIT_CONFIG_* environment variables, so it is never in argv or .git/config. An empty value first clears any header the caller's checkout set for the same URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting GIT_CONFIG_* entries

Review findings on the token fetch:
- Under RUNNER_DEBUG, set -x traced the token and its base64 before ::add-mask:: took effect. fetch_before now turns tracing off for its own body.
- GIT_CONFIG_COUNT=2 replaced any command-scoped config already in the environment (e.g. a runner's http.proxy). The two entries are now appended after the existing ones, exported in a subshell so the credential is not in any argv.
- The comment now says that a header configured for a more specific URL takes precedence.
- Tests: the shim logs every config entry, so the reset entry is checked; new tests for existing entries and for the trace; the fixture runner clears GITHUB_TOKEN, GITHUB_SERVER_URL, RUNNER_DEBUG and GIT_CONFIG_COUNT from the developer's environment; the git path in the shim is quoted; the unfalsifiable .git/config check is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
before is passed to git fetch and git show. A value starting with "-" was
read as an option: --upload-pack=<command> ran the command against a
local origin. Accept only 40 or 64 hexadecimal characters, and give the
all-zero SHA of a new branch its own error instead of a failed fetch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The versions come from package.json and are printed and substituted into
the prefixes. A version containing a newline followed by "::" was printed
as a workflow command. Fail with a clear error if either version, at
before or at HEAD, is missing or not semver.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tree

With skip-checkout the caller's checkout may have uncommitted changes, and
an uncommitted version bump in package.json counted as a release of the
pushed commit. Read package.json with git show HEAD:package.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a shallow clone

The script fetched `before` on every run, and in a shallow clone a fetch
without --depth downloads every ancestor of `before`, not just that
commit. On a single-commit push, `before` is HEAD^ and already in the
checkout (fetch-depth 2), so the fetch was not needed at all.

Check for `before` first and fetch only when it is missing; the
single-commit case then makes no network call and doesn't use the token.
In a shallow clone, fetch with --depth=1. A full clone (possible with
skip-checkout) is fetched into without --depth, so it isn't made shallow.
The fallback warning for a failed fetch with `before` present is gone: a
fetch now happens only when `before` is missing, so a failure is an error.

The script reads only `before`'s package.json, so the shallow boundary at
`before` doesn't matter.

Suggested by Joshua Fernandes in review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add fixture tests for `before` already present (no fetch, token unused,
an unreachable origin doesn't fail the run, no warning), missing from a
shallow clone (only that commit fetched, clone stays shallow), missing
from a full clone (clone not made shallow), and a failed fetch (error).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@joshuafernandes joshuafernandes 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.

LGTM, awesome work @rekmarks-consensys-1

@rekmarks-consensys-1
rekmarks-consensys-1 merged commit ef68f71 into main Nov 30, 2026
93 checks passed
@rekmarks-consensys-1
rekmarks-consensys-1 deleted the ocap/npm-is-release branch November 30, 2026 23:02
joshuafernandes pushed a commit that referenced this pull request Dec 1, 2026
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