From c54717268bf3e8b5b17be98946d5b955b85cd1c4 Mon Sep 17 00:00:00 2001 From: cmp-202 Date: Wed, 18 Nov 2026 18:34:23 +1300 Subject: [PATCH] docs: add release cadence and changelog guard --- .github/workflows/ci.yml | 3 ++ .github/workflows/live.yml | 6 ++- CHANGELOG.md | 6 +++ docs/PUBLISHING.md | 56 ++++++++++++++++++++++++--- package.json | 3 +- scripts/check-changelog.js | 78 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 145 insertions(+), 7 deletions(-) create mode 100644 scripts/check-changelog.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ddc9ac..e7f6e3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,9 @@ jobs: - name: Install run: npm ci + - name: Check changelog + run: npm run check:changelog + - name: Test current and baseline run: npm test diff --git a/.github/workflows/live.yml b/.github/workflows/live.yml index a266745..ed9378e 100644 --- a/.github/workflows/live.yml +++ b/.github/workflows/live.yml @@ -20,7 +20,11 @@ permissions: concurrency: group: live-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + # This workflow also runs as a reusable workflow from publish.yml. Cancelling + # a same-ref run could remove the required "Live suite" check from a PR or the + # live gate from a publish. Serialize instead; separate runners mean parallel + # live runs do not contend for ports. + cancel-in-progress: false jobs: live: diff --git a/CHANGELOG.md b/CHANGELOG.md index a254aff..1964451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ Releases before `4.0.0` are recorded as git tags and GitHub Releases. - Added live coverage for keyboard-interactive authentication on a nested hop and for `abortOnSudoFailure`, plus deterministic tests that feed one PTY transcript through `onData` at every chunk boundary. +- Added `npm run check:changelog` to CI and `prepublishOnly`, and documented the + release-cadence, release-candidate review, changelog, and registry-propagation + procedures in `docs/PUBLISHING.md`. +- Live workflow runs with the same ref now queue instead of cancelling each + other, so a parallel publish or push cannot remove a PR's required + `Live suite` check. ## [4.0.4] - 2026-11-18 diff --git a/docs/PUBLISHING.md b/docs/PUBLISHING.md index 7c064be..5aa556b 100644 --- a/docs/PUBLISHING.md +++ b/docs/PUBLISHING.md @@ -1,5 +1,27 @@ # Publishing ssh2shell +## Release cadence + +Merge work to `master` continuously through pull requests and let a batch of +changes settle. A green merge is **not** a release event; it is fine for `master` +to be ahead of npm `latest`. + +Release only on a trigger: + +- a security or critical fix, +- a user-facing bug fix, +- a new feature, +- or a milestone explicitly called by the maintainer. + +Test-only, docs-only, and CI-only changes do not trigger a release on their own. +They ride along with the next triggered release. Do not publish a version solely +to deliver internal work. + +Before tagging, run the external/free review against the **release candidate** +(the release branch or the merge commit on `master`), not against an already +published tag. Fix its actionable findings in the same release. Avoid a +same-day follow-up release unless the issue is critical. + ## One-off interactive publish `npm publish` requires a one-time password when 2FA is enabled: @@ -47,8 +69,23 @@ For a new version: ```bash npm version --no-git-tag-version -# update REFACTORING.md, CHANGELOG.md, and docs as needed git switch -c release/X.Y.Z +``` + +Update the changelog in a fixed order: + +1. Insert `## [X.Y.Z] - YYYY-MM-DD` above the existing `## [Unreleased]` + section. Move the release's `###` groups and bullets under it, remove empty + groups, and leave `[Unreleased]` in place for future work. +2. Add `[X.Y.Z]: https://github.com/cmp-202/ssh2shell/compare/vPREVIOUS...vX.Y.Z` + to the link definitions at the bottom. +3. Point the existing `[Unreleased]` link at `compare/vX.Y.Z...HEAD`. +4. Run `npm run check:changelog`. It fails if the version, date, bullets, or + compare links are missing, and it runs again from `prepublishOnly`. + +Then update `REFACTORING.md` and any other affected docs, and push the branch: + +```bash git add package.json package-lock.json REFACTORING.md CHANGELOG.md docs git commit -m "chore: release X.Y.Z" git push -u origin release/X.Y.Z @@ -81,8 +118,10 @@ npm view ssh2shell version npm view ssh2shell@X.Y.Z dist.tarball ``` -The registry can take a minute or two to show the new `latest` after the -workflow succeeds. Confirm the published `gitHead` matches the release commit: +The registry can take a minute or two (sometimes longer) to show the new +`latest` after the workflow succeeds. If the first check still shows the old +version, retry for a few minutes before treating it as a failed publish. Confirm +the published `gitHead` matches the release commit: ```bash npm view ssh2shell@X.Y.Z gitHead @@ -94,10 +133,17 @@ git rev-parse HEAD Run this list for every release so the steps that are easy to forget are not left to memory. +- [ ] Confirm a release trigger exists (security/critical fix, user-facing fix, + feature, or an explicitly called milestone). Do not release test/docs/CI + work on its own. - [ ] Decide the semver level from the commits since the last tag. +- [ ] Run the external/free review on the release candidate and resolve its + actionable findings in the same release. - [ ] `npm version --no-git-tag-version`. -- [ ] Update `REFACTORING.md`, `CHANGELOG.md`, and any docs affected by the - release. +- [ ] Move `[Unreleased]` entries under a dated version heading, add its compare + link, and update the `[Unreleased]` link. +- [ ] Update `REFACTORING.md` and any docs affected by the release. +- [ ] `npm run check:changelog` passes. - [ ] `npm test` passes (`check:build`, unit, baseline). - [ ] Run the live suite locally when the change touches connection or command flow: `npm run test:live:all`. diff --git a/package.json b/package.json index f41c312..0522460 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "scripts": { "build": "node scripts/build.js", "check:build": "node scripts/check-build.js", + "check:changelog": "node scripts/check-changelog.js", "test": "npm run check:build && npm run test:unit && npm run test:baseline", "test:unit": "node scripts/run-tests.js lib", "test:src": "node scripts/run-tests.js src", @@ -28,7 +29,7 @@ "test:live": "node scripts/run-live.js", "test:live:all": "node scripts/run-live.js --all", "provision": "node test/provision/provision.js", - "prepublishOnly": "npm test" + "prepublishOnly": "npm run check:changelog && npm test" }, "keywords": [ "SSH", diff --git a/scripts/check-changelog.js b/scripts/check-changelog.js new file mode 100644 index 0000000..394ff82 --- /dev/null +++ b/scripts/check-changelog.js @@ -0,0 +1,78 @@ +'use strict'; + +// Fails when a version is about to ship without a matching CHANGELOG entry. +// Run in CI on every pull request and again from `prepublishOnly`, so a release +// branch cannot bump package.json without documenting the release. + +const fs = require('node:fs'); +const path = require('node:path'); + +const repoRoot = path.join(__dirname, '..'); +const packagePath = path.join(repoRoot, 'package.json'); +const changelogPath = path.join(repoRoot, 'CHANGELOG.md'); + +const version = JSON.parse(fs.readFileSync(packagePath, 'utf8')).version; +const changelog = fs.readFileSync(changelogPath, 'utf8').replace(/\r\n?/g, '\n'); + +function escapeRegExp(value) { + return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} + +const errors = []; + +if (!/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(version)) { + errors.push(`package.json has an unsupported version: ${version}`); +} + +if (!/^## \[Unreleased\]\s*$/m.test(changelog)) { + errors.push('CHANGELOG.md is missing a "## [Unreleased]" section'); +} + +const heading = new RegExp( + `^## \\[${escapeRegExp(version)}\\] - (\\d{4}-\\d{2}-\\d{2})\\s*$`, + 'm' +); +const match = changelog.match(heading); + +if (!match) { + errors.push( + `CHANGELOG.md is missing a dated "## [${version}] - YYYY-MM-DD" heading` + ); +} else { + const start = match.index + match[0].length; + const next = changelog.indexOf('\n## [', start); + const section = changelog.slice(start, next === -1 ? undefined : next); + + if (!/^\s*[-*] \S/m.test(section)) { + errors.push(`the ${version} changelog section has no bullet entries`); + } +} + +const versionLink = new RegExp( + `^\\[${escapeRegExp(version)}\\]: https://github\\.com/cmp-202/ssh2shell/compare/\\S+`, + 'm' +); +if (!versionLink.test(changelog)) { + errors.push(`CHANGELOG.md is missing a compare link for [${version}]`); +} + +const unreleasedLink = new RegExp( + `^\\[Unreleased\\]: https://github\\.com/cmp-202/ssh2shell/compare/v${escapeRegExp( + version + )}\\.\\.\\.HEAD\\s*$`, + 'm' +); +if (!unreleasedLink.test(changelog)) { + errors.push( + `[Unreleased] must compare from v${version} to HEAD (update it when you bump the version)` + ); +} + +if (errors.length > 0) { + for (const error of errors) { + console.error(`changelog check failed: ${error}`); + } + process.exit(1); +} + +console.log(`changelog OK for ${version}`);