Skip to content

Commit fd4dc72

Browse files
rhyslbwclaude
andcommitted
chore(release): add yarn release:refs helper to list release refs
Since workflow_dispatch dropdowns can't be populated from git history, this prints recent release (version) commits so a maintainer can copy a real release ref to nominate for the release workflow's `ref` input, annotating each with the @cardano-sdk/core version it carries as a quick anchor to confirm a ref's versions before nominating it. Implemented as release-refs.mjs (matching collectCoverage.mjs): invokes git via execFileSync (no shell — portable, no quoting pitfalls), and filters on the commit subject (stable + rc) with an authoritative regex in JS, so reverts and merge commits that merely mention the subject in their body don't leak in (`--grep` is only a coarse pre-filter, since it matches the whole message). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 545a7f5 commit fd4dc72

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"version:stable": "lerna version --conventional-graduate --allow-branch master --create-release github -m \"ci: publish packages [skip actions]\" --sign-git-commit",
3737
"publish:rc": "lerna publish from-package --dist-tag rc --yes",
3838
"publish:stable": "lerna publish from-package --yes",
39+
"release:refs": "node release-refs.mjs",
3940
"test": "yarn workspaces foreach -v run test",
4041
"test:build:verify": "yarn workspaces foreach -v run test:build:verify",
4142
"test:e2e": "yarn workspaces foreach -v run test:e2e",

release-refs.mjs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Lists recent release (version) commits with the @cardano-sdk/core version each carries,
2+
// so a maintainer can nominate a real release ref (and its versions) for the `release`
3+
// workflow's `ref` input. workflow_dispatch dropdowns can't be populated from git history,
4+
// so this is the discovery aid. See .github/workflows/release.yaml.
5+
import { execFileSync } from 'node:child_process';
6+
7+
// Invoke git directly (no shell) — portable and free of quoting pitfalls.
8+
const git = (...args) => execFileSync('git', args, { encoding: 'utf8' });
9+
10+
// Authoritative match is on the commit SUBJECT (stable + rc). `git log --grep` matches the
11+
// whole message (subject + body), so it's only a coarse pre-filter to keep the walk cheap;
12+
// this regex then drops anything (reverts, merges) that merely mentions the subject in its body.
13+
const SUBJECT_RE = /^ci: publish (rc )?packages \[skip actions\]$/;
14+
const limit = Number.parseInt(process.argv[2], 10) || 20;
15+
const US = '\x1f'; // unit separator — a field delimiter that can't appear in the log fields
16+
17+
const rows = git('log', '-F', '--grep=ci: publish', `--format=%h${US}%H${US}%ci${US}%s`, '-n', String(limit * 3))
18+
.split('\n')
19+
.filter(Boolean)
20+
.map((line) => line.split(US))
21+
.filter(([, , , subject]) => SUBJECT_RE.test(subject))
22+
.slice(0, limit);
23+
24+
if (rows.length === 0) {
25+
console.log('No release commits found.');
26+
process.exit(0);
27+
}
28+
29+
for (const [short, full, date] of rows) {
30+
let version = '?';
31+
try {
32+
version = JSON.parse(git('show', `${full}:packages/core/package.json`)).version;
33+
} catch {
34+
// packages/core/package.json may not exist at very old commits — leave as '?'
35+
}
36+
console.log(`${short} core@${version.padEnd(11)}${date}`);
37+
}

0 commit comments

Comments
 (0)