Skip to content

Conversation

@sheplu
Copy link
Member

@sheplu sheplu commented Jan 14, 2026

Setup to be done on the repository:

  • create dedicated environment (npm here, can be changed to publish)
  • restrict access to environment to specific branch
  • add review of pipeline by other people (optional ?)

Setup to be done on npm:

  • Go to the package
  • Setup trusted publisher with repository + environment + name of the workflow

@bjohansebas
Copy link
Member

see https://github.com/expressjs/codemod/settings/environments/9670255041/edit, the enviroment config for codemod

@sheplu sheplu force-pushed the add-trusted-publisher branch from d602cdf to c374a35 Compare January 14, 2026 22:00
@@ -0,0 +1,38 @@
name: Publish package
Copy link
Member

Choose a reason for hiding this comment

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

Naming nit-picks:

  1. file name: could we go with release.yaml?
  2. worfklow name: could we go with just Publish?
  3. environment name: could we use npm?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated, I am fine with the new name

Copy link
Member

@blakeembrey blakeembrey Jan 15, 2026

Choose a reason for hiding this comment

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

Oh, I reviewed first (missing old comments) and disagreed. I think these should all match to simplify debugging of action <> env <> file. So all should be publish or release. With three different names it's confusing for someone new or returning.

Edit: Personally I'd name it publish because it's npm publish and not npm release.

Copy link
Member

Choose a reason for hiding this comment

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

It'd be like creating a ci.yaml called name: Test running in env node. Hard to debug/review.

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 will align everything to "publish" if everyone is fine with that :D

npm version $VERSION --no-git-tag-version
else
echo "Version already set to $VERSION, skipping npm version command"
fi
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this version logic is quite right. In order to create a release you first need a versioned commit with a tag so I think you either need to change the trigger or change this logic.

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 is a specific logic (working) that basically put the tag from the github release (suggesting that we tag the release with v1.1.1)
In the case of our project, as we are manually updating tags on the package.json file I can fully remove that? what would be the way you would like to see it?

@UlisesGascon ?

Copy link
Member

Choose a reason for hiding this comment

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

I think it should not automatically version, but instead exit if it doesn't match.

@sheplu sheplu force-pushed the add-trusted-publisher branch from c374a35 to 5228ed5 Compare January 14, 2026 22:08
jobs:
publish:
runs-on: ubuntu-latest
environment: npm
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Would name it Release (or both Publish) to make it easier to debug/find.

@@ -0,0 +1,38 @@
name: Publish
Copy link
Member

Choose a reason for hiding this comment

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

Nit: The name of the file is release.yaml but the script Publish, would be nicer to align them.

name: Publish
on:
release:
types: [created]
Copy link
Member

Choose a reason for hiding this comment

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

I'd do on tag, because otherwise you are releasing without having a release actually available for anyone. This is doubly so with the environment approval and/or NPM staged publishing, it could be hours before the "release" is actually available.

@UlisesGascon
Copy link
Member

Oh! I thought we wanted to address this approach first #142... but if you prefer to try this one we can go, but it will be hard (open a request to support) to revert it if we want to use CI publication again right?

@sheplu
Copy link
Member Author

sheplu commented Jan 15, 2026

Oh! I thought we wanted to address this approach first #142... but if you prefer to try this one we can go, but it will be hard (open a request to support) to revert it if we want to use CI publication again right?

you mean on NPM?
No, based on NPM you cannot "force" only to use trusted publisher, you can only (at best) restrict to use token with 2fa so you can always do a publish using a token (and not from the workflows)

As we discussed yesterday about NPM trusted publisher and that we wanted something directly in the repo, I just opened this PR

@sheplu sheplu force-pushed the add-trusted-publisher branch from 5228ed5 to df526fd Compare January 15, 2026 19:30
Copy link
Member

@blakeembrey blakeembrey left a comment

Choose a reason for hiding this comment

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

I’d also be for not pinning the official actions but that’s up to the maintainers.

on:
push:
tags:
- '*.*.*'
Copy link
Member

Choose a reason for hiding this comment

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

Add v in front?

@UlisesGascon UlisesGascon mentioned this pull request Jan 19, 2026
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.

5 participants