Skip to content

Feat: Add release CI #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Feat: Add release CI #64

wants to merge 4 commits into from

Conversation

Totto16
Copy link
Collaborator

@Totto16 Totto16 commented Mar 24, 2025

Add a release CI

This runs on every prerelease and release, and published the package automatically to npm, so we don't have to do that manually.

If it is a pre-release, it is published under the next tag, otherwise under the latest tag.

This was not tested as a whole yet (as it is not possible to test everything together that easily), but it should work, once
all TODO's are done. I tested every step of the pipeline separately locally, the pipeline was run nearly identical already on a test repo of mine (without npm publish)

Additionally I updated the normal Ci, to also use the newest Node LTS version and cleaned it up a bit.

Links

What is Provenance: https://docs.npmjs.com/generating-provenance-statements
GH example for publishing packages: https://docs.github.com/de/actions/use-cases-and-examples/publishing-packages/publishing-nodejs-packages

TODO

@Totto16 Totto16 requested a review from JumpLink March 24, 2025 21:45
add `id-token` write permissions, so that provenacne works correctly
Copy link
Collaborator

@swsnr swsnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea, but since this is a shared repository we need a bit of security in place to avoid someone stealing the token for releases. In particular, we might want to provide collaborators with write access, while still not permitting them to do releases.

Specifically, I think we need to

  • make sure that the NPM_TOKEN is only available to workflows on tags and the main branch,
  • in other words, make sure that the token is never available in other branches or pull requests, even from this repo, and
  • setup CODEOWNERS to enforce review and approval for all changes to workflows by repo owners (and not just repo collaborators).

I don't actually know how to set that up with Github actions, but I think it's mandatory to have this secured.

@Totto16
Copy link
Collaborator Author

Totto16 commented Mar 25, 2025

I think this is a good idea, but since this is a shared repository we need a bit of security in place to avoid someone stealing the token for releases. In particular, we might want to provide collaborators with write access, while still not permitting them to do releases.

Specifically, I think we need to

* make sure that the NPM_TOKEN is only available to workflows on tags and the main branch,

* in other words, make sure that the token is never available in other branches or pull requests, even from this repo, and

* setup CODEOWNERS to enforce review and approval for all changes to workflows by repo owners (and not just repo collaborators).

I don't actually know how to set that up with Github actions, but I think it's mandatory to have this secured.

I agree in general with your view, but GH actions and secrets are safe, and can't be retrieved in any way.

Edit: I get the exploit that might reveal the secret (creating a PR, that changes the CI, to echo the secrets, it runs automatically and prints the secret)

However, making the token only available on certain branches (e.g. main ) should be possible. There is good documentation for that, AFAIK we need to just make a branch rule / ruleset, where we add the secret just for those branches.

I don't think setting up CODEOWNERS is necessary and there is only the option, that only CODEOWNERS can approve PR's, there is no scope, that restricts chnages in workflows.

@swsnr
Copy link
Collaborator

swsnr commented Mar 25, 2025

In the code owners file you declare that only e.g. repo owners are code owners of workflows files, and then Github requires a review from these people.

I think that this is mandatory to prevent unauthorised modifications to workflows.

@Totto16
Copy link
Collaborator Author

Totto16 commented Mar 25, 2025

In the code owners file you declare that only e.g. repo owners are code owners of workflows files, and then Github requires a review from these people.

I think that this is mandatory to prevent unauthorised modifications to workflows.

I never used that feature, so I am not familiar with that. But if it's possible, It's a good idea. 👍🏼

@JumpLink
Copy link
Collaborator

JumpLink commented Mar 25, 2025

Thanks a lot and great idea! I'll have a look at this over the next few days and enter the NPM token in a secure way and then give appropriate feedback 👍

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.

3 participants