Skip to content

Conversation

@sheplu
Copy link
Member

@sheplu sheplu commented Nov 4, 2025

Create one reusable action for release purpose

  • release allow secure publication with multiple validation required
    • user should have the permission to create a tag / release
    • an approved member (environment protection) need to approve the workflow
    • the 2FA from NPM is asked everytimes - using the wait-for-secrets action
    • npm publish rely on a granular token with mandatory 2FA
    • the token is stored in an environment that is bound to a specific protected branch / tag

@sheplu sheplu force-pushed the release-reusable-action branch 5 times, most recently from d15e2f9 to b29aecb Compare January 4, 2026 06:31
@sheplu sheplu force-pushed the release-reusable-action branch from b29aecb to dda3ea9 Compare January 4, 2026 10:08
- Use a **granular npm token** scoped only to the package(s) being published
- The token must have **publish-only permissions**
- The token should be **added shortly before each publish**
- The token must be **revoked immediately after the deployment completes**
Copy link
Member

Choose a reason for hiding this comment

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

Ideally this needs to be automated (high chances we forget as local logout) but the CLI requires the ID: npm token revoke <token-id> so in that case we need to add an additional secret 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

This would be great to not need a specific PAT token for that :) I am still hoping that we can have tokens that are deleted automatically after a short time or after a number of usage (1 would be perfect).

For this workflows, I am not sure about the case to have a token to delete a token, and then delete the token used to delete the token 😅


Only workflows explicitly targeting `environment: publish` will be able to access these secrets.

## Behavior
Copy link
Member

Choose a reason for hiding this comment

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

There are some repos (probably more in the future) that might not work with this approach as they require a build step before release like codemod: (https://github.com/expressjs/codemod/blob/35e5d273b5530b4a1e2352cc849612ee39d929b6/package.json#L29)

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking of allowing the call of the action with a specific npm script to run for that. Would you have anything against ? Or do you see a specific way?

Copy link
Member

Choose a reason for hiding this comment

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

We don’t need to worry about codemod, because it has a different setup for publishing (see https://github.com/expressjs/codemod/blob/main/.github/workflows/publish.yml and expressjs/codemod#100), which we’re going to start using soon.

id-token: write
contents: read

jobs:
Copy link
Member

Choose a reason for hiding this comment

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

I definitely will like to pin dependencies here as our tokens are used in this workflow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixing that in a couple minutes !

Comment on lines +20 to +22
steps:
- name: Checkout
uses: actions/checkout@v6
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
steps:
- name: Checkout
uses: actions/checkout@v6
steps:
- name: Harden Runner
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@v6

Obviously we need to use egress-policy: block once the allowedlist is clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Absolutely! Nothing against that - in the contrary it will be way better.

As this is not yet setup, I only included the base workflow

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