npm: a push to the mirror's main publishes iterate under main, with no approval #26
merged kernel-npm-hands-free was squashed into main as 7454b19 by jonas, 2026-11-27 17:49 UTC. jonas opened it 2026-11-27 17:49 UTC.
Misha's answer on the card tasks/build-and-validate-the-standalone-npm-publisher.md (27 Nov 2026, 17:48 UTC): "hands-free. it should publish the way we used to: the format was like 0.4.1-main.20261126T222208Z-ca5d72a ... for ordinary commits to main, make it hands-free like it was before we started moving off github". Two files: - .github/workflows/npm-publish.yml: the publish job runs for a push to main of github.com/iterate/kernel and publishes under the tag main when core/lib's packed files changed; latest follows main, as iterate/private's workflow did. A dispatch still does dry-run, canary, main and check. The header says who can publish: whoever can put a commit on the source's main. - .github/npm-publish.mjs: a run that was held back does not move a tag to an older commit's version. The setting that goes with it, on GitHub: the environment npm of iterate/kernel loses its required reviewers. It still takes main alone. The reviewer's read (on the card) says this gives kernel main's writers the publish; Misha chose that for builds of main. Session: claude 11c408f7-7edb-4a8d-8a49-8382fb8307e6 on beelink 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Conversation
Nobody has said anything yet.
Sign in to comment or to merge.
Files
2 files changed
M .github/npm-publish.mjs
@@ -119,8 +119,7 @@ const manifestPath = join(work, "packed/package/package.json"); const { devDependencies: _d, ...manifest } = JSON.parse(readFileSync(manifestPath, "utf8")); - if (manifest.name !== name) - throw new Error(`${folder} holds ${manifest.name}, not ${name}`); + if (manifest.name !== name) throw new Error(`${folder} holds ${manifest.name}, not ${name}`); const version = versionAt({ version: manifest.version, distTag, committedAt, sha }); writeFileSync( manifestPath, @@ -200,6 +199,16 @@ throw new Error(`${name}@${version} was not packed for the dist-tag ${distTag}`); const npm = await packumentOf(name); const last = await publishedAt(name, distTag, work); + // a run that was held back: the dist-tag names a later commit's version already. The date + // leads the version, so text order is commit order. + if ( + last && + last.version.startsWith(`${version.split("-")[0]}-${distTag}.`) && + last.version > version + ) + return await say( + `npm \`${distTag}\` names ${last.version}, which is later than ${version}: not published`, + ); const unchanged = last && !differs(filesOf(join(work, "packed/package")), last.files); const has = Boolean(npm?.versions[version]); const names = unchanged ? last.version : version; @@ -251,13 +260,9 @@ const missing = await missingOnNpm(NAME, oidc); if (!missing) return await say(`npm is ready for this workflow to publish ${NAME}.`); await say( - [ - `${missing.said}. As someone who may publish it:`, - "", - "```sh", - ...missing.setup, - "```", - ].join("\n"), + [`${missing.said}. As someone who may publish it:`, "", "```sh", ...missing.setup, "```"].join( + "\n", + ), ); throw new Error(`npm is not ready for ${NAME}`); }
M .github/workflows/npm-publish.yml
@@ -4,8 +4,9 @@ # publishing takes an OIDC token from GitHub's own runners alone. The package's settings on # npmjs.com name that repository, this file and the environment `npm`. # -# A push to main packs the package and installs it, and publishes nothing. A dispatch on main names -# what to do with main's tip: +# A push to main publishes the package under the tag `main` and moves `latest` to it, when its +# packed files changed, with no person: `0.4.1-main.<commit date>-<sha>` says that it is a build +# of a commit and no release. A dispatch on main names something else to do with main's tip: # # gh workflow run npm-publish.yml --repo iterate/kernel -f action=<dry-run | canary | main | check> # @@ -14,9 +15,9 @@ # installs passed, with no script of it run. `check` asks npm, as this workflow, whether the # package trusts it; it writes and removes the tag `npm-publish-check` and nothing else. # -# `publish` and `check` wait for a person: the environment `npm` has required reviewers. That gate -# is a setting on GitHub, so no commit here can remove it. Without it, a commit that edits this -# file could publish, and mirror.yml brings every commit of the source's main. +# WHO PUBLISHES: whoever can put a commit on main of the source, because mirror.yml brings every +# such commit here and this file is part of it. Misha chose that on 27 Nov 2026 for builds of main; +# a real release gets a person's approval when there is one. on: push: branches: @@ -32,10 +33,11 @@ - main - check default: dry-run -# One run at a time for an action, in order, and no run is cancelled: a publish that was cut off -# could leave `latest` behind `main`. +# One run at a time for a dist-tag, in order, and no run is cancelled: a publish that was cut off +# could leave `latest` behind `main`. A run that waits is replaced by a newer one, which publishes +# what both changed. concurrency: - group: npm-${{ inputs.action || 'push' }} + group: npm-${{ inputs.action || 'main' }} cancel-in-progress: false permissions: {} jobs: @@ -89,11 +91,11 @@ path: ${{ runner.temp }}/tarball - run: node .github/npm-publish.mjs install --tarball "$(ls "$RUNNER_TEMP"/tarball/*.tgz)" # npm gets the tarball that both installs passed, as it is: no script of the package runs here. - # Only a dispatch on main that names a dist-tag gets here. The environment `npm` takes main - # alone, and a reviewer of it approves the job. + # Only main gets here: a push, or a dispatch that names a dist-tag. The environment `npm` takes + # main alone. publish: needs: [pack, install] - if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && (inputs.action == 'canary' || inputs.action == 'main') + if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || inputs.action == 'canary' || inputs.action == 'main') runs-on: ubuntu-latest environment: npm permissions: @@ -116,7 +118,7 @@ path: ${{ runner.temp }}/tarball - run: node .github/npm-publish.mjs publish --tarball "$(ls "$RUNNER_TEMP"/tarball/*.tgz)" --dist-tag "$DIST_TAG" env: - DIST_TAG: ${{ inputs.action }} + DIST_TAG: ${{ inputs.action || 'main' }} check: if: github.repository == 'iterate/kernel' && github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && inputs.action == 'check' runs-on: ubuntu-latest