dhoulb / multi-semantic-release

Proof of concept that wraps semantic-release to work with monorepos.
BSD Zero Clause License
203 stars 36 forks source link

MSR fails on npm version step in workspaces #112

Closed deanohyeah closed 2 years ago

deanohyeah commented 2 years ago

After NPM V8.5 MSR fails to properly version packages.

The cause seems to be rooted in NPM version here. https://github.com/npm/cli/commit/723a0918a5a9d9f795584f85d04506fafda9ca42

npm version now triggers an update. This causes MSR to fail because it hasn't updated the version numbers to the packages workspace dependencies.

command: 'npm version 1.1.17 --userconfig /private/var/folders/ma/04c2f7cs14lf92g8gf2dsq/T/fa64d3b635b5700135e79f5158c3/.npmrc --no-git-tag-version --allow-same-version',
  escapedCommand: 'npm version 1.1.17 --userconfig "/private/var/folders/ma/04c2f7c4lf92g8gf2ds1sc0000gq/T/fa2a9d64d635b5700135e79f5158c3/.npmrc" --no-git-tag-version --allow-same-version',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: '@ui/user\nv1.1.17',
  stderr: 'npm ERR! code ETARGET\n' +
    'npm ERR! notarget No matching version found for @ui/dropdown@1.10.0.\n' +
    'npm ERR! notarget In most cases you or one of your dependencies are requesting\n' +
    "npm ERR! notarget a package version that doesn't exist.\n" +
    '\n' +
    'npm ERR! A complete log of this run can be found in:\n' +

Since this behavior is now default, would need to some how get a --no-workspaces-update to semantic releases use of npm version in https://github.com/semantic-release/npm/blob/master/lib/prepare.js#L12

antongolub commented 2 years ago

Similar issues raises in yarn 2+. We use a semrel/exec-based workaround:

module.exports = {
  branch: 'master',
  plugins: [
    [
      '@semantic-release/commit-analyzer',
      {
        preset: 'angular',
        releaseRules: [
          {type: 'docs', release: 'patch'},
          {type: 'refactor', release: 'patch'},
        ],
        parserOpts: {
          noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES']
        }
      }
    ],
    '@semantic-release/release-notes-generator',
    '@semantic-release/changelog',
    [
      '@semantic-release/exec',
      {
        prepareCmd: 'YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install && git add ../../yarn.lock',
      }
    ],
    '@semrel-extra/npm',
    '@semantic-release/github'
    ...
deanohyeah commented 2 years ago

@antongolub thank you for the suggestion!

I was actually able to get it to work by running npm config set workspaces-update false before the MSR command I wasn't aware that was a valid config

antongolub commented 2 years ago

Great! Maybe you'd lke to add some notes to the readme.md troubleshooting section?

deanohyeah commented 2 years ago

Sure thing, how bout this #113