Update CHANGELOG entry when npm version is ran instead of only through GitHub Actions workflow#7078
Merged
Conversation
📋 StatsNo changes to any distributed file sizes! Action run for 07d026c |
NickColley
commented
May 20, 2026
domoscargin
reviewed
May 20, 2026
5cf0992 to
a64fe77
Compare
1091285 to
87ee7c2
Compare
87ee7c2 to
1b8c7e8
Compare
1b8c7e8 to
40c6aff
Compare
domoscargin
reviewed
May 20, 2026
Contributor
domoscargin
left a comment
There was a problem hiding this comment.
Looks good - a few comments from me
40c6aff to
0f559be
Compare
0f559be to
5f394e7
Compare
5f394e7 to
7656e89
Compare
NickColley
commented
May 21, 2026
Member
romaricpascal
left a comment
There was a problem hiding this comment.
Script looks neat and good find about the env variables for the versions when npm invokes it 🙌🏻
I think Babel doesn't need updating, though, as it's not part of the process for running the script.
7656e89 to
e684f6d
Compare
e684f6d to
003cb77
Compare
003cb77 to
0f591ab
Compare
Update the CHANGELOG entry using the "postversion" lifecycle hook which will execute after the `npm version` is completed. > If preversion, version, or postversion are in the scripts property of the package.json, they will be executed as part of running npm version. > The exact order of execution is as follows: > 1. Check to make sure the git working directory is clean before we get started. Your scripts may add files to the commit in future steps. This step is skipped if the --force flag is set. > 2. Run the preversion script. These scripts have access to the old version in package.json. A typical use would be running your full test suite before deploying. Any files you want added to the commit should be explicitly added using git add. > 3. Bump version in package.json as requested (patch, minor, major, etc). > 4. Run the version script. These scripts have access to the new version in package.json (so they can incorporate it into file headers in generated files for example). Again, scripts should explicitly add generated files to the commit using git add. > 5. Commit and tag. > 6. Run the postversion script. Use it to clean up the file system or automatically push the commit and/or tag. https://docs.npmjs.com/cli/v11/commands/npm-version#description Uses undocumented environment variables to get both the old and new versions: https://github.com/npm/cli/blob/c97b39b1e3436cd20a67ab5f4012a5f395c538b9/workspaces/libnpmversion/lib/version.js#L100-L103
0f591ab to
07d026c
Compare
Contributor
Author
|
Example run with all the existing changes: |
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.
Update the CHANGELOG entry using the "postversion" lifecycle hook which will execute after the
npm versionis completed.https://docs.npmjs.com/cli/v11/commands/npm-version#description
Uses undocumented environment variables to get both the old and new
versions:
https://github.com/npm/cli/blob/c97b39b1e3436cd20a67ab5f4012a5f395c538b9/workspaces/libnpmversion/lib/version.js#L100-L103
Closes #7033