Nx publish is releasing all the packages in independent mode with wrong tags
I am running into a weird issue where the NX release and publish are not in sync. I cannot commit the package.json's back to my repo for security reasons, however I can publish tags and changelogs. Given, two packages:
- package-a, version: 0.0.0-sem-released, tag: package-a@1.2.0
- package-b, version: 0.0.0-sem-released, tag: package-b@2.4.5
when I make a conventional commit to package-b with feat: and publish, I getting following changes:
NX version
update package-b/package.json
- "version": "0.0.0-sem-released"
+ "version": "2.5.0"
NX release
nx-release-publish:package-a
Added the dist-tag latest to 0.0.0-sem-released # <--- this is wrong
nx-release-publish:package-b
... build logs
Added the dist-tag latest to 2.5.0
- Why
nx publishrunning for a package that has no release on it and tagging it? - How can I fix this? I want NX to publish only versioned packages, not all
- GH Copilot suggested setting "release.publish.onlyReleased" in nx.json, but it doesn't do anything, nor is it a valid option per the schema.
- I am currently running a shell script to get the tags from the current branch and update the package.json myself, but this feels unnecessary. Is there a way I can avoid it?
❯ nx release --printConfig
{
"version": {
"preVersionCommand": "sh scripts/sync-package-versions.sh && pnpm exec nx run-many -t build -p packages/*",
"conventionalCommits": true,
"preserveLocalDependencyProtocols": false
},
"git": {
"commit": false,
"tag": true
},
"conventionalCommits": {
"types": {
"perf": {
"semverBump": "patch"
}
}
},
"changelog": {
"projectChangelogs": {
"file": false,
"createRelease": {
"apiBaseUrl": "https://github.private.com/api/v3",
"provider": "github-enterprise-server",
"hostname": "github.private.com"
}
}
},
"releaseTag": {
"pattern": "{projectName}@{version}"
},
"projectsRelationship": "independent"
}
NX Report complete - copy this into the issue template
Node : 24.11.1
OS : darwin-arm64
Native Target : aarch64-macos
pnpm : 10.29.3
daemon : Available
nx : 22.4.2
@nx/js : 22.4.2
@nx/workspace : 22.4.2
@nx/devkit : 22.4.2
typescript : 5.9.3
---------------------------------------
Please, I appreciate any help!