Ali Hassan
Ali Hassan

Reputation: 198

Issues with lerna independent versioning + Github Actions

this is the first time i am working with lerna and i am having some trouble with the independent versioning, just to start off i ran lerna init without --independent and i added that in the lerna.json later on after i published the initial version.

i am using Github Actions for CI and everything is working ok but lerna keeps on publishing new versions of the package i have even though i don't make changes to it, for example if i add somethings to the README file it will still update the version of the package i have and publish a new version, i am using conventional commits with it as well.

here is my lerna.json

{
  "packages": [
    "packages/*"
  ],
  "version": "independent",
  "npmClient": "npm",
  "workspaces": true,
  "command": {
    "publish": {
      "conventionalCommits": true,
      "message": "chore: new release"
    }
  }
}

i tried deleting all tags and running a build with a change to the package to deploy another version but still every other change that happens outside the package triggers a new release for the package..

Upvotes: 3

Views: 6470

Answers (1)

Luís Brito
Luís Brito

Reputation: 1772

Changes to source files will trigger publishing, unless the ignore-changes flag is set. It has its own limitations, take a look at this issue with a similar use case: https://github.com/lerna/lerna/issues/2437. The conventional-commits will help with the right SemVer tag, but it will at least generate a patch upgrade, for let's say your README.md file updates. It won't prevent a release from being made.

You need to handle it outside of lerna, and invoke lerna publish conditionally only when you are sure the changes are relevant. The lerna changed command can help you with a preview of what lerna is seeing as a changed package.

Also, lerna will publish child packages when a parent has changed. This can lead to confusions and potential mistakes, remember to take that into account.

Upvotes: 1

Related Questions