-
Notifications
You must be signed in to change notification settings - Fork 2.3k
lerna version not creating correct tags since lerna@7.3.0 when signing commits and tags #3916
Description
Current Behavior
Since lerna@7.3.0, using the --sign-git-commit and --sign-git-tag flags causes lerna version to always create 0 and 1 as tags in a repository with two projects inside it.
This happens both when running the command locally or in a workflow and might have to do with me setting up my git config to sign commits already.
The full command is yarn lerna version --conventional-commits --message "chore: bump version" --force-git-tag --sign-git-commit --sign-git-tag --yes --loglevel silly. Running the command without the two flags related to signing fixes the issue. Running the command with lerna@7.2.0 with the two flags also fixes the issue.
The version bump inside package.json seems correct, but the tags are always 0 and 1:
Expected Behavior
This is a regression bug. I've found that using lerna@7.2.0 still creates the tags correctly when signing.
The created tags should reflect the version set in package.json. Like so:
Steps to Reproduce
- Can you reproduce this on https://github.com/lerna/repro?
Yes. This is visible here - https://github.com/ivml/lerna-repro
The repo has an initial commit setting up 2 projects with a single md file inside. For each subsequent commit, I change the md files so that it causes a version bump. Then, the next commits do the following:
- a small change to the markdown files while using
lerna@7.2.0. This correctly causes the CI/CD to do a minor bump. - another small change which also bumps
lernato 8.0.0. This causes the CI/CD to create the 0 and 1 tags. This commit causes the issue. - dropping the two flags from the command (done in the next commit) fixes the issue and my workflow creates the correct tags again - seen in this run.
- reverting the version to 7.2.0 while keeping the two flags to sign commits and tags works correctly.
The same behavior is observed with versions 7.3.0 and 7.4.2.
Failure Logs / Configuration
lerna.json
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"npmClient": "yarn",
"version": "independent",
"changelog": {
"preset": "angular",
"compareUrlFormat": "https://github.com/ivml/lerna-repro/compare/{{previousTag}}...{{currentTag}}"
}
}lerna-debug.log
yarn run v1.22.21
$ /home/runner/work/lerna-repro/lerna-repro/node_modules/.bin/lerna version --conventional-commits --message 'chore: bump version' --force-git-tag --sign-git-commit --sign-git-tag --yes --loglevel silly
lerna sill argv {
lerna sill argv _: [ 'version' ],
lerna sill argv 'conventional-commits': true,
lerna sill argv conventionalCommits: true,
lerna sill argv message: 'chore: bump version',
lerna sill argv m: 'chore: bump version',
lerna sill argv 'force-git-tag': true,
lerna sill argv forceGitTag: true,
lerna sill argv 'sign-git-commit': true,
lerna sill argv signGitCommit: true,
lerna sill argv 'sign-git-tag': true,
lerna sill argv signGitTag: true,
lerna sill argv yes: true,
lerna sill argv y: true,
lerna sill argv loglevel: 'silly',
lerna sill argv lernaVersion: '8.0.0',
lerna sill argv '$0': 'node_modules/.bin/lerna'
lerna sill argv }
lerna notice cli v8.0.0
lerna verb packageConfigs Resolving packages based on package.json "workspaces" configuration.
lerna verb rootPath /home/runner/work/lerna-repro/lerna-repro
lerna info versioning independent
lerna info ci enabled
lerna sill isAnythingCommitted
lerna verb isAnythingCommitted 1
lerna sill getCurrentBranch
lerna verb currentBranch main
lerna sill remoteBranchExists
lerna sill isBehindUpstream
lerna sill isBehindUpstream main is behind origin/main by 0 commit(s) and ahead by 0
lerna sill hasTags
lerna verb hasTags true
lerna sill git-describe.sync "first-project@1.1.0-1-g606cf31" => {"lastTagName":"first-project@1.1.0","lastVersion":"1.1.0","refCount":"1","sha":"606cf31","isDirty":false}
lerna info Looking for changed packages since first-project@1.1.0
lerna sill checking diff packages/first-project
lerna sill found diff in packages/first-project/foo.md
lerna verb filtered diff [ 'packages/first-project/foo.md' ]
lerna sill checking diff packages/second-project
lerna sill found diff in packages/second-project/bar.md
lerna verb filtered diff [ 'packages/second-project/bar.md' ]
lerna verb updated first-project
lerna verb updated second-project
lerna verb git-describe undefined => "first-project@1.1.0-1-g606cf31"
lerna sill git-describe parsed => {"lastTagName":"first-project@1.1.0","lastVersion":"1.1.0","refCount":"1","sha":"606cf31","isDirty":false}
lerna sill independent for first-project at /home/runner/work/lerna-repro/lerna-repro/packages/first-project
lerna verb getChangelogConfig using preset "conventional-changelog-angular"
lerna sill npa Result {
lerna sill npa type: 'tag',
lerna sill npa registry: true,
lerna sill npa where: undefined,
lerna sill npa raw: 'conventional-changelog-angular',
lerna sill npa name: 'conventional-changelog-angular',
lerna sill npa escapedName: 'conventional-changelog-angular',
lerna sill npa scope: undefined,
lerna sill npa rawSpec: '',
lerna sill npa saveSpec: null,
lerna sill npa fetchSpec: 'latest',
lerna sill npa gitRange: undefined,
lerna sill npa gitCommittish: undefined,
lerna sill npa hosted: undefined
lerna sill npa }
lerna verb getChangelogConfig Attempting to resolve preset "conventional-changelog-angular"
lerna info getChangelogConfig Successfully resolved preset "conventional-changelog-angular"
lerna verb independent increment 1.1.0 by minor
lerna sill independent for second-project at /home/runner/work/lerna-repro/lerna-repro/packages/second-project
lerna verb independent increment 1.1.0 by minor
Changes:
- first-project: 1.1.0 => 1.2.0
lerna info auto-confirmed
- second-project: 1.1.0 => 1.2.0
lerna info execute Skipping releases
lerna sill lifecycle No script for "preversion" in "lerna-repro", continuing
lerna sill lifecycle No script for "preversion" in "first-project", continuing
lerna sill lifecycle No script for "preversion" in "second-project", continuing
lerna verb version first-project has no lockfile. Skipping lockfile update.
lerna verb version second-project has no lockfile. Skipping lockfile update.
lerna sill lifecycle No script for "version" in "second-project", continuing
lerna sill independent for second-project at /home/runner/work/lerna-repro/lerna-repro/packages/second-project
lerna sill lifecycle No script for "version" in "first-project", continuing
lerna sill independent for first-project at /home/runner/work/lerna-repro/lerna-repro/packages/first-project
lerna sill independent writing new entry: "# [1.2.0](https://github.com/***/lerna-repro/compare/second-project@1.1.0...second-project@1.2.0) (2023-12-04)\n\n\n### Features\n\n* added more headings and bumped lerna to 8.0.0 ([606cf31](https://github.com/***/lerna-repro/commit/606cf3123940e7f44de01d21ec9fd91af4f1c1f2))\n\n\n\n"
lerna sill independent writing new entry: "# [1.2.0](https://github.com/***/lerna-repro/compare/first-project@1.1.0...first-project@1.2.0) (2023-12-04)\n\n\n### Features\n\n* added more headings and bumped lerna to 8.0.0 ([606cf31](https://github.com/***/lerna-repro/commit/606cf3123940e7f44de01d21ec9fd91af4f1c1f2))\n\n\n\n"
lerna verb independent wrote /home/runner/work/lerna-repro/lerna-repro/packages/second-project/CHANGELOG.md
lerna verb independent wrote /home/runner/work/lerna-repro/lerna-repro/packages/first-project/CHANGELOG.md
lerna sill lifecycle No script for "version" in "lerna-repro", continuing
lerna verb version Detected yarn version 1.22.21
lerna sill gitAdd [
lerna sill gitAdd 'packages/second-project/package.json',
lerna sill gitAdd 'packages/first-project/package.json',
lerna sill gitAdd 'packages/second-project/CHANGELOG.md',
lerna sill gitAdd 'packages/first-project/CHANGELOG.md'
lerna sill gitAdd ]
lerna sill gitCommit chore: bump version
lerna sill gitCommit
lerna sill gitCommit - first-project@1.2.0
lerna sill gitCommit - second-project@1.2.0
lerna verb git [
lerna verb git 'commit',
lerna verb git '--gpg-sign',
lerna verb git '-F',
lerna verb git '/tmp/2ad33cb3-1be3-4059-bb01-970de58bdfa7/lerna-commit.txt'
lerna verb git ]
lerna sill gitTag 0 git tag %s -m %s
lerna verb git [ 'tag', '0', '-m', '0', '--force', '--sign' ]
lerna sill gitTag 1 git tag %s -m %s
lerna verb git [ 'tag', '1', '-m', '1', '--force', '--sign' ]
lerna sill lifecycle No script for "postversion" in "first-project", continuing
lerna sill lifecycle No script for "postversion" in "second-project", continuing
lerna sill lifecycle No script for "postversion" in "lerna-repro", continuing
lerna info git Pushing tags...
lerna sill gitPush origin main
lerna success version finished
Done in 2.67s.
Everything up-to-dateEnvironment
npx lerna info
lerna notice cli v8.0.0
lerna info versioning independent
Environment info:
System:
OS: macOS 14.1
CPU: (10) x64 Apple M1 Pro
Binaries:
Node: 18.18.2 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.8.1 - /usr/local/bin/npm
Utilities:
Git: 2.39.3 - /usr/bin/git
npmPackages:
lerna: 8.0.0 => 8.0.0 As seen in the commits, having my CI/CD and local environment configured to sign commits via git config commit.gpgsign true and tags via git config tag.gpgsign true seems to interfere with lerna version --sign-git-commit --sign-git-tag. It's entirely possible to circumvent the issue by just dropping the two flags, but I believe for the sake of transparency, this should either be fixed or documented.
Note: the commits and tags show up as unverified as I have revoked the associated GPG key since reproducing the issue.

