Skip to content

ci: refactor workflows to support trusted publishing / OIDC#554

Open
ryepup wants to merge 2 commits into
mainfrom
491-trusted-publishers
Open

ci: refactor workflows to support trusted publishing / OIDC#554
ryepup wants to merge 2 commits into
mainfrom
491-trusted-publishers

Conversation

@ryepup
Copy link
Copy Markdown
Collaborator

@ryepup ryepup commented May 22, 2026

Proposed changes

The existing workflow had a few quirks:

  • combined PRs and merging to main, creating a broader attack surface
  • published to npm and then made a git tag. If the git step failed we might have a published package version without a matching tag.
  • relied on some github default permissions that could get overridden at the org level to improve security.
  • tried to npm publish when our dev dependencies change, and failed because the package version was already there. This was some useless noise.

Given the recent spate of npm supply chain attacks, I wanted to revamp this and get a little more explicit.

  • split up the PR, tag, and npm publish to three workflows with their own explicit permissions
    • the PR workflow runs build/test (reads git)
    • the tag workflow creates a tag after merging to main (read/write to git)
    • the publish workflow uses trusted publishing to publish the package (reads git, writes to npm)
  • disable caching during npm publish to dodge the cache poisoning attacks like https://tanstack.com/blog/npm-supply-chain-compromise-postmortem. I don't think we were vulnerable to the same things, but github actions is kinda a mess security wise so I'm feeling paranoid
  • tweak the tag script to be a no-op if the package.json version hasn't changed.

fixes #490, fixes #26

Also adds an explicit dependency to tslib to try to get the workflows to actually pass. See #546

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • I have updated any relevant documentation (README.md and CHANGELOG.md)

ryepup added 2 commits May 22, 2026 14:51
The existing workflow had a few quirks:

- combined PRs and merging to `main`, creating a broader attack surface
- published to npm and _then_ made a git tag. If the git step failed we might have a published package version without a matching tag.
- relied on some github default permissions that could get overridden at the org level to improve security.
- tried to `npm publish` when our dev dependencies change, and failed because the package version was already there. This was some useless noise.

Given the recent spate of npm supply chain attacks, I wanted to revamp this and get a little more explicit.

- split up the PR, tag, and npm publish to three workflows with their own explicit `permissions`
  - the PR workflow runs build/test (reads git)
  - the tag workflow creates a tag after merging to main (read/write to git)
  - the publish workflow uses [trusted publishing](https://docs.npmjs.com/trusted-publishers) to publish the package (reads git, writes to npm)
- disable caching during `npm publish` to dodge the cache poisoning attacks like <https://tanstack.com/blog/npm-supply-chain-compromise-postmortem>. I don't think we were vulnerable to the same things, but github actions is kinda a mess security wise so I'm feeling paranoid
- tweak the tag script to be a no-op if the `package.json` version hasn't changed.

fixes #490, fixes #26
Seems to be a bug with how `@rollup/plugin-typescript` specifies it's dependencies; it lists `tslib` as an optional peer dependency, and `npm ci` will _sometimes_ install `tslib`. See rollup/plugins#1533

It used to work after enough CI retries, but I'm not getting lucky today. Adding `tslib` explicity seems to fix it.

fixes #546
@ryepup ryepup requested review from danielledeleo and thresheek May 22, 2026 20:13
@ryepup ryepup linked an issue May 22, 2026 that may be closed by this pull request
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.

flaky CI job use NPM "trusted publishers" instead of tokens spurious build failures

1 participant