Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/live.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
56 changes: 51 additions & 5 deletions docs/PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -47,8 +69,23 @@ For a new version:

```bash
npm version <major|minor|patch> --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
Expand Down Expand Up @@ -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
Expand All @@ -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 <major|minor|patch> --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`.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
78 changes: 78 additions & 0 deletions scripts/check-changelog.js
Original file line number Diff line number Diff line change
@@ -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}`);
Loading