intuit / auto

Generate releases based on semantic version labels on pull requests.
https://intuit.github.io/auto/
MIT License
2.28k stars 204 forks source link

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

Open jonathantredway opened 2 years ago

jonathantredway commented 2 years ago

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

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?

Domitnator commented 2 years ago

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

tshamz commented 1 year ago

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

hipstersmoothie commented 1 year ago

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