ci: refactor workflows to support trusted publishing / OIDC#554
Open
ryepup wants to merge 2 commits into
Open
Conversation
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
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
The existing workflow had a few quirks:
main, creating a broader attack surfacenpm publishwhen 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.
permissionsnpm publishto 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 paranoidpackage.jsonversion hasn't changed.fixes #490, fixes #26
Also adds an explicit dependency to
tslibto try to get the workflows to actually pass. See #546Checklist
Before creating a PR, run through this checklist and mark each as complete.
CONTRIBUTINGdocumentREADME.mdandCHANGELOG.md)