Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-semantic-release changes the "workspace:^" while versioning #85

Closed
Code2Life opened this issue Nov 4, 2021 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@Code2Life
Copy link

While using PNPM workspace in monorepo, dependencies could be:

"somePkg" : "workspace:^"

However, semantic release will change it to 1.0.x when writing version back to package.json.

Expect Behavior:

Remain original string: "workspace:^", otherwise, pnpm install will resuilt in wrong module structure.

@antongolub antongolub added the bug Something isn't working label Nov 4, 2021
@antongolub
Copy link
Collaborator

antongolub commented Nov 4, 2021

@Code2Life,

Thanks for the report. Here's how semrel npm plugin updates package version:

module.exports = async (npmrc, {tarballDir, pkgRoot}, {cwd, env, stdout, stderr, nextRelease: {version}, logger}) => {
  const basePath = pkgRoot ? path.resolve(cwd, pkgRoot) : cwd;

  logger.log('Write version %s to package.json in %s', version, basePath);

  const versionResult = execa(
    'npm',
    ['version', version, '--userconfig', npmrc, '--no-git-tag-version', '--allow-same-version'],
    {
      cwd: basePath,
      env,
    }
  );

And here's the place, where msr can just override package.json.version value:

const prepare = async (pluginOptions, context) => {
	// Wait until the current pkg is ready to be tagged
	getLucky("_readyForTagging", pkg);
	await waitFor("_readyForTagging", pkg);

	updateManifestDeps(pkg);
	pkg._depsUpdated = true;

	const res = await plugins.prepare(context);
	pkg._prepared = true;

	debug("prepared: %s", pkg.name);

	return res;
};

But it may affect other plugins prepare result (like commit creation). I don't see a quick fix for the problem.

@Code2Life
Copy link
Author

@antongolub Thank you !
Currently I removed "package.json" file from "@semantic-release/git" releaserc to avoid this issue, even it will cause inconsistency of "real" version.

@antongolub
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants