Feature Request: Configuration option to disable publishing by default in nx release (opt-in publishing for CI/CD safety)
#33954
ThePlenkov
started this conversation in
Feature Requests
Replies: 2 comments 2 replies
-
|
Wow it's surprising this isn't already an option - I am just moving our publishing step to our gitlab-ci, very surprised there is no option in nx.json to prevent publishing locally. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Edit : Just noticed the option now exists : https://nx.dev/docs/guides/nx-release/publish-in-ci-cd#automatically-skip-publishing-locally |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Current Behavior
When running
nx release, the command will both version and publish packages by default. To prevent publishing, developers must remember to add the--skip-publishflag every time they run the command locally.# Current approach - easy to forget --skip-publish nx release --skip-publishThis creates a safety concern where developers might accidentally publish packages from their local machines if they forget the flag.
Expected Behavior
There should be a workspace-level configuration option to disable publishing by default, requiring an explicit opt-in flag to publish. This would enforce that publishing only happens in controlled CI/CD environments.
Proposed configuration in
nx.json:{ "release": { "version": { // ... version config }, "publish": { "skipByDefault": true // or "requireExplicitPublish": true } } }With this configuration:
Motivation
1. Safety First
Publishing should be an intentional, controlled action that happens only in CI/CD pipelines, not accidentally from developer machines.
2. Enforce Best Practices
Many organizations require that all releases go through CI/CD for:
3. Developer Experience
--skip-publishevery time4. Alignment with CI/CD Workflows
The official Nx documentation recommends using
--skip-publishlocally, but this should be enforceable at the workspace level rather than relying on developer discipline.Suggested Implementation
Option 1: Configuration-based (Preferred)
Add a configuration option in
nx.json:{ "release": { "publish": { "skipByDefault": true } } }When
skipByDefault: true:nx release→ skips publishing (safe default)nx release --publish→ explicitly publishesnx release --skip-publish=false→ explicitly publishesOption 2: Environment Variable Detection
Automatically skip publishing unless running in CI environment:
{ "release": { "publish": { "onlyInCI": true } } }This would check for common CI environment variables (
CI=true,GITHUB_ACTIONS,GITLAB_CI, etc.)Option 3: Both
Combine both approaches for maximum flexibility.
Alternate Implementations
--skip-publish, have--publishbe required whenskipByDefault: truenx release versionandnx release publishas distinct commandsUse Case
Our organization (and many others) have a policy that:
Currently, we have to:
--skip-publish" in our guidelinesWith this feature, we could:
nx.json--publishflag in CI/CD scripts (making intent clear)Related Documentation
The Nx team already recommends this pattern in the Publish in CI/CD guide, but it should be enforceable through configuration rather than convention.
Additional Context
This is similar to how other package managers handle publishing:
npm publishcommandpnpm publishcommandchangeset versionandchangeset publishcommandsThe request is to bring similar safety to
nx releasethrough configuration.Would the Nx team be open to this feature? I'm happy to contribute a PR if this aligns with the project's direction.
Beta Was this translation helpful? Give feedback.
All reactions