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

feat: additional arguments publishArgs and versionArgs for npm commands #534

Closed
wants to merge 3 commits into from

Conversation

1aron
Copy link

@1aron 1aron commented Dec 7, 2022

I built my own monorepo ecosystem based on semantic release.

During the NPM release process, I encountered resistance, so I added two conservative features.

Since specifying a workspace in .npmrc such as workspace=packages will change the behavior of executing npm run in the root directory, we usually don't want to store .npmrc, and NPM will not automatically read the .workspaces settings in package.json when running npm publish and npm version, which is quite inconvenient.

Of course, we can execute echo -e "\nworkspace=packages/**/*" >> .npmrc on CI, but as mentioned above, it will affect the execution of subsequent instructions, which will make the command of the project not predictable.

Before submitting this PR I removed @semantic-release/npm package and solved my problem in publishCmd:

{
     "publishCmd": "npm publish --workspace=packages"
}

But I found that I was missing a lot of the benefits that @semantic-release/npm brought me.

You can see the use cases I added in the README:

{
     "publishArgs": ["--workspace", "packages"],
     "versionArgs": ["--workspace", "packages"]
}

These test cases were failing before I made any changes:

Screenshot 2022-12-08 at 12 07 57 AM

I even use it on the Master CSS open source project, which is a monorepo, and it works nicely with Semantic Release.

This is not a monorepo-specific feature, but this can be very useful in monorepo projects with multiple packages. Hope this feature passes quickly, thanks to the Semantic Release team for all you do.

@1aron
Copy link
Author

1aron commented Dec 8, 2022

I've published my changes as aron-semantic-release-npm and it works perfectly fine in practice:

Screenshot 2022-12-08 at 1 39 25 PM

https://github.com/1aron/aronrepo/actions/runs/3645164693/jobs/6155064392#step:6:275

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant