Skip to content
Advertisement

How to update the package.json version using semantic-release/git?

What I want to do

Based on the FAQ

https://semantic-release.gitbook.io/semantic-release/support/faq#why-is-the-package.jsons-version-not-updated-in-my-repository

I want to update the package.json version number on a new release.


What I did

  • Create a new empty private Github repository for an organization temp with a README.md and .gitignore for node
  • Clone the repository
  • Fix the first commit message via git rebase -i --root and change it to feat: initial commit
  • Create a package.json with the content
JavaScript
  • Setup semantic-release
JavaScript
  • Create a .releaserc.json
JavaScript
  • Create a new Github workflow release.yml
JavaScript
  • Commit everything with the message feat: next commit
  • Force push to origin

The problem

The package.json file won’t get updated by the semantic-release-bot. Even after modifying the README.md file and pushing with feat: this should trigger a new release.

image

How can I tell semantic-release to push the new package version?

Advertisement

Answer

Based on this issue

https://github.com/semantic-release/semantic-release/issues/1593

you also need the npm module.

  • npm install @semantic-release/npm -D
  • add "private": true, to your package.json if you don’t want to publish to npm
  • add the npm plugin to the release configuration file (the order matters)

.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement