auto icon indicating copy to clipboard operation
auto copied to clipboard

versionBranches throws when version is set to "independent" in lerna.json

Open jonathantredway opened this issue 2 years ago • 3 comments

Describe the bug

When versionBranches has a value in .autorc and "version" is set to "independent" in lerna.json, the version produced here is an empty string (from this ternary), causing SemVer to throw TypeError: Invalid Version: .

To Reproduce

  • Set versionBranches to any string value in your autorc.
  • Set "version": "independent" in your lerna.json.
  • Run auto shipit in ci by merging a PR with the major version label to the baseBranch.

Expected behavior

shipit is successful and a branch is created to version the major release.

Screenshots

.autorc

# only publish/release if a PR has the 'release' label
onlyPublishWithReleaseLabel: true

# when a major version is released, a branch prefixed 'release/' will be created and the release tag created from it
versionBranches: 'release/'

lerna.json

{
    "packages": ["core", "hotkeys", "ui", "timestamps"],
    "version": "independent",
    "npmClient": "yarn",
    "useWorkspaces": "true"
}

Stack Trace:

info      Using monorepo to calculate previous release
ℹ  info      NPM: Got previous version from package.json 
ℹ  info      Adding new changes to changelog.
ℹ  info      Old changelog exists, prepending changes.
ℹ  info      Wrote new changelog to filesystem.
ℹ  info      Using monorepo to calculate previous release
ℹ  info      NPM: Got previous version from package.json 
TypeError: Invalid Version: 
    at new SemVer (/home/runner/work/frost-packages/frost-packages/node_modules/@auto-it/core/node_modules/semver/classes/semver.js:38:13)
    at Object.major (/home/runner/work/frost-packages/frost-packages/node_modules/@auto-it/core/node_modules/semver/functions/major.js:2:29)
    at /home/runner/work/frost-packages/frost-packages/node_modules/@auto-it/core/src/auto.ts:464:59
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Additional context

As I linked in the description, this ternary seems very suspicious. Why does it produces the package list on new lines in dryrun and an empty string otherwise?

jonathantredway avatar May 04 '22 16:05 jonathantredway

I am running into this bug as well! Is there a temporary workaround?

Domitnator avatar Jun 21 '22 06:06 Domitnator

did anybody figure this out? any workarounds? @Domitnator, @jonathantredway, mom, God...? Anybody?

tshamz avatar Dec 16 '22 20:12 tshamz

Version branches might get kinda hectic with independent mode. Currently this is not supported and I don't think I have the time to dig into it

hipstersmoothie avatar May 11 '23 02:05 hipstersmoothie