question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lerna always using a patch version when using conventional commits

See original GitHub issue

We recently integrated automatic releases with Lerna by using execa, --yes, and a combination of other args. This is the gist of our script.

First we version:

execa('lerna', [
  'version',
  '--yes',
  // Only run on master
  '--allow-branch',
  'master',
  // Use the ESLint conventional commit preset
  '--conventional-commits',
  '--changelog-preset',
  'eslint',
  // Create a GitHub release
  '--github-release',
  // Push changes to git
  '--push',
  // Alter commit message to skip CI
  '--message',
  'Release [ci skip]',
])

And then publish later on:

execa('lerna', [
  'publish',
  'from-git',
  '--yes',
  // Run pre and post scripts in each package if available
  '--require-scripts',
])

We’re using the ESLint conventional commit preset, but no matter what our commit messages look like, the release is always a patch version. For example, our latest commit message was “New: Add util to handle render props”, which should be a minor release, but was a patch.

Expected Behavior

It determines the correct version.

Current Behavior

It’s always a patch version.

Possible Solution

Not sure. I’m digging into execa to see if that’s the cause, but I have yet to find anything. Looking for any information that may help here as it’s blocking our releases.

Steps to Reproduce (for bugs)

Try running those example scripts above I suppose.

lerna.json

{
  "version": "independent",
  "npmClient": "yarn",
  "useWorkspaces": true,
  "command": {
    "publish": {
      "ignoreChanges": ["*.md"]
    }
  }
}

Context

Your Environment

Executable Version
lerna --version 3.11.1
npm --version 6.5.0
yarn --version 1.13.0
node --version 10.14

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
HW13commented, Jun 8, 2021

I was having this issue, but only when trying to use --conventional-commits in a github action. I was able to get it to work by configuring actions/checkout@v2 to fetch my repo’s entire history (docs). By default only the latest commit is fetched, so I assume the empty commit history was the cause of my problem.

Hopefully this can help someone else:

- uses: actions/checkout@v2
  with:
    fetch-depth: 0
1reaction
milesjcommented, Feb 14, 2019

FOUND IT! I threw some console logs in here:

getChangelogConfig cache undefined
parsed { type: 'tag',
  registry: true,
  where: undefined,
  raw: 'eslint',
  name: 'eslint',
  escapedName: 'eslint',
  scope: undefined,
  rawSpec: '',
  saveSpec: null,
  fetchSpec: 'latest',
  gitRange: undefined,
  gitCommittish: undefined,
  hosted: undefined }
trying without prefix eslint { Linter: [Function: Linter],
  CLIEngine:
   { [Function: CLIEngine] version: '5.13.0', getFormatter: [Function: getFormatter] },
  RuleTester:
   { [Function: RuleTester] [Symbol(it)]: null, [Symbol(describe)]: null },
  SourceCode: [Function: SourceCode] }

Since we try without the prefix, eslint loads the actual eslint package instead of conventional-changelog-eslint.

It should probably be updated to try with the prefix before trying without the prefix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Can Lerna bump prerelease version according to ...
It doesn't seem that Lerna 3.20. 2 is able to bump prerelease versions (e.g. 1.0. 0-alpha. 0 ) according to the Conventional Commits...
Read more >
@lerna/version - npm
Releases all unreleased changes as pre(patch/minor/major/release) by prefixing the version recommendation from conventional-commits with pre , ...
Read more >
@lerna/conventional-commits | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
Monorepo using Lerna, Conventional commits, and Github ...
We will now publish the very first version of the package to the Github Packages npm registry, so we can install it from...
Read more >
Automating package publishing in JavaScript projects
This post shows you how to automate package versioning and publishing to the registry, using some helpful tools like Lerna and Commitizen.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found