4 Commits
Author SHA1 Message Date
GandClaude Fable 5 047dc691e2 chore(release): 0.1.1 — reconcile releases, publish via trusted publishing (#9)
Ports ai-forms' publish reconciler: merging a version bump to main is the
whole release. The workflow (on push, hourly, or by hand) asks the registry
whether package.json's version exists and publishes it if not — idempotent,
and immune to the tag-pushed-by-GITHUB_TOKEN trigger gap.

Auth is OIDC via the package's Trusted Publisher (this repo + publish.yml),
so no npm token exists to leak or expire. The bump to 0.1.1 makes the merge
itself prove the tokenless path live.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-21 01:25:50 +02:00
6b24a59011 chore: ignore per-session worktrees (#2)
A worktree under .claude/ is a full copy of the repo, dist/ included.
Left untracked it gets picked up as source — in ai-forms an identical
setup made the lint gate report 10 errors that were all in a stale
worktree, and blocked a release for reasons that had nothing to do with
the code being released.

Co-authored-by: Mao Nakamoto <georgy.butaev@revamp-it.ch>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 01:03:49 +02:00
GandClaude Opus 5 743c8f62dd ci: make the release a reconciler, not a trigger (#8)
Mirrors ai-forms#17, where this was not theoretical: that repo's merge to main
started no publish run, because auto-merge merges with GITHUB_TOKEN and a push
with that token starts no workflow. The identical change fired here only
because I merged this repo's PR by hand with a user token.

threadkit has no auto-merge today, which is exactly why the schedule belongs
here now — rather than being added after auto-merge arrives and a release
quietly goes missing.

The question the workflow asks — "is package.json's version on the registry?" —
is idempotent, so asking it hourly costs one `npm view` when there is nothing to
do and repairs a missed release when there is.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 20:19:13 +02:00
GandClaude Opus 5 a6687547b6 ci: release without anyone running a release (#7)
Mirrors ai-forms#16 so both libraries release identically.

Cutting a release meant `npm version && git push --tags` by hand. Now merging a
version bump to main ships the package: the workflow asks the registry whether
package.json's version already exists and publishes it if not.

That check rather than a tag trigger, because a tag pushed by GITHUB_TOKEN does
not start another workflow — "push a tag, let publish.yml notice" silently never
runs — and because asking npm what is published is idempotent, so a re-run or a
hand-pushed tag cannot double-publish. The tag is created after a successful
publish, so it never claims a release that did not happen.

NPM_TOKEN expires 2026-11-14. token-health.yml probes `npm whoami` weekly and
opens a single issue when it fails, with the fix in it — rather than letting a
release three months from now be the thing that discovers the expiry, reported
as a 403 that reads like a permissions problem.

Verified: both files parse, and the registry check answers correctly against the
real registry for threadkit@0.1.0 (already published → skip).

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 18:26:35 +02:00
5 changed files with 148 additions and 34 deletions

No files matched your search

+59 -31
View File
@@ -1,18 +1,36 @@
name: Publish
# Publishing is driven by a version tag, so the released artifact is always
# traceable to a commit. `npm version` creates the tag; pushing it ships.
# Releasing is not a thing anyone does. Merge a version bump to main and the
# package ships: this workflow asks the registry whether package.json's version
# already exists, and publishes it if not.
#
# Why that check rather than a tag trigger: a tag pushed by GITHUB_TOKEN does
# not start another workflow, so "push a tag, let publish.yml notice" silently
# never runs. Asking npm what is published is also idempotent — re-running this,
# or pushing a tag by hand, cannot double-publish or fail confusingly.
on:
push:
branches: [main]
tags: ['v*']
# The reconciler, and the reason this is reliable. A merge made by auto-merge
# uses GITHUB_TOKEN, and a push with that token starts no workflow — so the
# push trigger above silently does not fire for exactly the merges that matter.
# The schedule asks the registry the same idempotent question on a timer: is
# package.json's version published? If a release was missed by any means, it
# goes out within the hour without anyone noticing it was missed.
schedule:
- cron: '43 * * * *'
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
# Required for npm provenance — proves on the registry that this tarball
# was built by this workflow from this commit.
# Tagging the released commit, so a version on the registry can always be
# traced back to the tree it was built from.
contents: write
# npm provenance: proves on the registry that this tarball was built by
# this workflow from this commit.
id-token: write
steps:
- uses: actions/checkout@v4
@@ -22,33 +40,43 @@ jobs:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- run: npm ci --ignore-scripts
# Never publish something that would not have passed CI.
- run: npm run verify
# Refuse to publish a tag whose version does not match package.json,
# rather than silently shipping the wrong number.
- name: Check tag matches package version
- name: Is this version already on the registry?
id: check
run: |
tag="${GITHUB_REF_NAME#v}"
pkg=$(node -p "require('./package.json').version")
if [ "$tag" != "$pkg" ]; then
echo "Tag v$tag does not match package.json version $pkg" >&2
exit 1
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
echo "version=$version" >> "$GITHUB_OUTPUT"
if npm view "$name@$version" version >/dev/null 2>&1; then
echo "→ $name@$version is already published; nothing to do."
echo "publish=false" >> "$GITHUB_OUTPUT"
else
echo "→ $name@$version is not on the registry; releasing it."
echo "publish=true" >> "$GITHUB_OUTPUT"
fi
# OIDC (id-token above) is the preferred credential and needs no secret.
# But trusted publishing is configured per package on npmjs.com, and a
# package that has never been published cannot have it configured — so
# OIDC alone cannot do the FIRST publish. Confirmed on ai-forms: the
# provenance statement was signed and logged to sigstore, then the PUT
# returned E404 "could not be found or you do not have permission",
# which reads like a missing package rather than a missing credential.
#
# NPM_TOKEN covers only that first publish. Once this package exists and
# a trusted publisher is configured, npm prefers OIDC and the secret can
# be deleted.
- run: npm publish
- if: steps.check.outputs.publish == 'true'
run: npm ci --ignore-scripts
# Never publish something that would not have passed CI.
- if: steps.check.outputs.publish == 'true'
run: npm run verify
# Auth is trusted publishing (OIDC): npm accepts this job's identity token
# because the package's Trusted Publisher is pinned to exactly this repo
# and workflow. No npm token exists anywhere, so none can leak or expire.
- if: steps.check.outputs.publish == 'true'
run: npm publish
- name: Tag the released commit
if: steps.check.outputs.publish == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
TAG: v${{ steps.check.outputs.version }}
run: |
# Tag after a successful publish, so a tag never claims a release that
# did not happen. Skipped silently if it already exists.
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "→ tag $TAG already exists"
else
git tag "$TAG"
git push origin "$TAG"
fi
+83
View File
@@ -0,0 +1,83 @@
name: Token health
# NPM_TOKEN expires. Without this, the thing that discovers that fact is a
# release failing months from now, at which point someone has to work out why —
# an npm auth error does not say "your token expired", it says 403 or ENEEDAUTH,
# which reads like a permissions problem.
#
# So the token is checked on a schedule and the failure is turned into an issue
# with the fix written in it, instead of a surprise during a release.
on:
schedule:
# Weekly, Monday 06:00 UTC.
- cron: '0 6 * * 1'
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Can the token still authenticate?
id: probe
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# `npm whoami` is the cheapest call that proves the credential is live.
# It does not publish, and it does not need a package to exist.
if who=$(npm whoami 2>&1); then
echo "→ token is valid (authenticated as $who)"
echo "ok=true" >> "$GITHUB_OUTPUT"
else
echo "→ token did NOT authenticate: $who"
echo "ok=false" >> "$GITHUB_OUTPUT"
fi
- name: Open an issue if the token is dead
if: steps.probe.outputs.ok != 'true'
uses: actions/github-script@v7
with:
script: |
const title = 'NPM_TOKEN cannot authenticate — releases are blocked';
// One open issue, not one per week.
const existing = await github.rest.issues.listForRepo({
owner: context.repo.owner, repo: context.repo.repo,
state: 'open', labels: 'release-blocked',
});
if (existing.data.some(i => i.title === title)) {
core.info('issue already open');
return;
}
await github.rest.issues.create({
owner: context.repo.owner, repo: context.repo.repo,
title,
labels: ['release-blocked'],
body: [
'`npm whoami` failed with the `NPM_TOKEN` secret, so **publishing is broken**.',
'Nothing is wrong with the package — the credential is.',
'',
'Most likely the token expired. npm tokens are created with an expiry,',
'and an expired one fails with `403`/`ENEEDAUTH`, which reads like a',
'permissions problem rather than an expiry.',
'',
'**Two ways to fix it, cheapest first:**',
'',
'1. **Configure trusted publishing and delete the token entirely.**',
' npmjs.com → this package → Settings → Trusted Publisher →',
' GitHub Actions → this org/repo → `publish.yml` → allow `npm publish`.',
' Then remove the `NODE_AUTH_TOKEN` line from `publish.yml`.',
' Tokens stop existing, so they stop expiring.',
' https://docs.npmjs.com/trusted-publishers',
'',
'2. Create a new granular token and re-set the secret:',
' `gh secret set NPM_TOKEN --repo ' + context.repo.owner + '/' + context.repo.repo + '`',
' (the secret NAME is `NPM_TOKEN`; the token itself is pasted at the prompt)',
].join('\n'),
});
+3
View File
@@ -1,3 +1,6 @@
node_modules/
dist/
*.tgz
# Per-session git worktrees. Never lint, test, or publish from these — a stale
# copy of the repo here is otherwise picked up as if it were source.
.claude/
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "threadkit",
"version": "0.1.0",
"version": "0.1.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "threadkit",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"devDependencies": {
"@eslint/js": "^9.39.5",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "threadkit",
"version": "0.1.0",
"version": "0.1.1",
"description": "Headless multi-participant message threads. Permission is participation, unread is per-person, and an AI can be a participant subject to the same visibility rules as everyone else.",
"license": "MIT",
"author": "Mao Nakamoto",