Skip to content

Add CI that tests every change and publishes from main - #1

Merged
benkelly merged 1 commit into
mainfrom
ci-publish-on-main
Aug 28, 2026
Merged

benkelly merged 1 commit into
mainfrom
ci-publish-on-main

Conversation

@benkelly

@benkelly benkelly commented Aug 28, 2026 •

Copy link
Copy Markdown
Owner

Two jobs in one workflow.

test runs npm test, the in-file self-check, on every pull request and on main. No dependencies, no lockfile, and it passes with no device and no socket attached. That check has caught four real regressions: Bun.connect failing silently, a cancelled turn repainting cyan, the multiple-choice prompt reading as work, and an icon branch the old test could not detect.

publish uses npm trusted publishing over OIDC. No token is stored or rotated, and CI cannot tap a YubiKey, so OIDC is the only workable route with 2FA enabled. npm adds provenance automatically for a public repository published this way.

Deliberate choices

  • Only publish when the version changed. Publishing an existing version fails with 409, so the job compares package.json against the registry first. Bump the version in the pull request and merging it releases. That fits the ruleset on main, which requires a pull request.

  • No npm ci. npm's own example includes it, but this package has no dependencies and no lockfile, so it would fail.

  • node, not bun, for the test script. The plugin now uses only Node standard library modules, and node is always on the runner.

  • No GitHub environment on the publish job. npm encourages one "for projects with maintainers who should not have npm publishing access", which is a multi-maintainer control. With a single maintainer the release is already gated where it matters: publish runs only on main, and reaching main requires a pull request. An environment would add a second approval granted by the same person.

    Add one the moment anybody else can merge to main, because at that point "can merge" and "can release" become the same permission. It is two changes, and they must agree exactly or the publish fails with ENEEDAUTH:

      publish:
        environment: release

    plus the same environment name in the npm trusted publisher configuration.

Required manual step before the first publish

The workflow will fail with ENEEDAUTH until a trusted publisher is registered. On npmjs.com, under the package Settings, add a GitHub Actions trusted publisher:

Field Value
Organization or user benkelly
Repository opencode-sidepulse
Workflow filename ci.yml
Allowed actions npm publish

The filename is case-sensitive and must include the extension. npm does not validate the configuration when saved, so a typo only shows up as a failed publish.

Once a publish has succeeded, consider setting Publishing access to "Require two-factor authentication and disallow tokens". Trusted publishing keeps working, and it closes off token-based publishing entirely.

Test job runs the self-check on pull requests and on main. It needs no
dependencies and no lockfile, and it passes with no device and no socket
attached, reporting both as absent.

Publish job uses npm trusted publishing over OIDC, so there is no token to
store or rotate, and a YubiKey cannot be tapped from CI anyway. npm adds
provenance automatically for a public repo published this way.

Publishing an existing version fails with 409, so the job only publishes when
the version in package.json differs from the registry. Bump the version in the
pull request and merging it releases. That suits the branch ruleset, which
requires a pull request and blocks direct pushes to main.

Drop npm ci from the published example, since this package has no dependencies
and no lockfile. Point the test script at node rather than bun, because the
plugin now uses only Node standard library modules and node is always present
on the runner.
@benkelly
benkelly merged commit 502e3b8 into main Aug 28, 2026
2 checks passed
@benkelly
benkelly deleted the ci-publish-on-main branch August 28, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant