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

npm will not publish unless nx project name matches folder name #65

Closed
Weetbix opened this issue May 5, 2023 · 14 comments
Closed

npm will not publish unless nx project name matches folder name #65

Weetbix opened this issue May 5, 2023 · 14 comments
Labels

Comments

@Weetbix
Copy link
Contributor

Weetbix commented May 5, 2023

Hey!

When the project name in project.json does not match the folder name, npm publish will not run during release, with this output:

[@semantic-release/npm] › ℹ  Skip publishing to npm registry as npmPublish is false

Imagine the setup like this:

.
└── packages/
    └── full-project-name/
        ├── package.json (name: "full-project-name")
        └── project.json (name: "short-name")

I think its due to this logic here but I did not confirm: https://github.dev/TheUnderScorer/nx-semantic-release/blob/55df58ca8416acaa61268e82c31c91ff623223fb/packages/nx-semantic-release/src/executors/semantic-release/plugins.ts#L22

Changing the nx project name to match the folder and package name solved the issue, but it would be nice to be able to use a shorthand name sometimes.

@TheUnderScorer
Copy link
Owner

Hey!

I'm not sure if that is the intended setup for the NX workspaces. I think that usually, the directory name should match the project name.

I'll see if I can tackle this in the next release, although it seems like a low-priority issue for now.

@doomietrue
Copy link

doomietrue commented May 8, 2023

Hi,

I am experiencing the same issue with npmPublish:false but seems the names are ok. My .nxrelease.json configuration file is set up as follows:

{
  "changelog": true,
  "npm": true,
  "github": false,
  "repositoryUrl": "ssh://git@stash.company.com:7999/monorepo.git",
  "outputPath" : "${WORKSPACE_DIR}/dist",
  "buildTarget": "build",
  "branches": ["master"]
}

in .npmrc registry set to company npm registry.

I run it with npx nx affected --base=master --target=semantic-release --parallel=false

I have 2 packages in nx monorepo and the following target

"semantic-release": {
      "executor": "@theunderscorer/nx-semantic-release:semantic-release"
    }

However, when I run the release process, the package is not being published to the npm registry. Instead, I see the following log message:

[semantic-release] [@semantic-release/npm] › ℹ  Skip publishing to npm registry as npmPublish is false

I have tried running nx-semantic-release in debug mode, but I didn't find any relevant errors or warnings related to publishing the package.

Could you please help me understand why the package is not being published, even though the npm option is set to true in my configuration? Is there any additional configuration or steps that I need to follow to ensure the package is published correctly?

Edit:
Disregard my comment, outputPath was wrong.
My apologies.

@daniel-clover
Copy link

daniel-clover commented Aug 30, 2023

I have a similar issue, I'm getting:
Skip publishing to npm registry as npmPublish is [secure]

my .nxrelease.jon

{ "changelog": true, "npm": true, "github": false, "repositoryUrl": "https://github.XXXXXX.com/clover/web-lib-sprout-design-system", "branches": [ "master" ] }

I've searched for this error, but came up with nothing.

Do you have any suggestions on what I could look for?

@daniel-clover
Copy link

daniel-clover commented Aug 31, 2023 via email

@ruscon
Copy link
Contributor

ruscon commented Aug 31, 2023

@daniel-clover

In general, you can avoid running this command: npx nx run-many --all --target build

You just need to fix your .nxreleaserc.json
change from

"buildTarget": "build",

to

"buildTarget": "${PROJECT_NAME}:build",

Then the build target will be called automatically

example of my .nxreleaserc.json

{
  "repositoryUrl": "git@github.com:XXX/YYY.git",
  "npm": true,
  "github": true,
  "changelog": false,
  "outputPath": "dist/${PROJECT_DIR}",
  "buildTarget": "${PROJECT_NAME}:build",
  "tagFormat": "${PROJECT_NAME}-v${VERSION}",
  "commitMessage": "chore(release): ${nextRelease.gitTag} [skip ci]\n\n${nextRelease.notes}",
  "branches": [
    "main"
  ]
}

@daniel-clover
Copy link

daniel-clover commented Aug 31, 2023 via email

@ruscon
Copy link
Contributor

ruscon commented Aug 31, 2023

@daniel-clover I'm not a developer of this repo :D
I just ran into the same problem :)

@ruscon
Copy link
Contributor

ruscon commented Aug 31, 2023

@daniel-clover I didn't see Skip publishing to npm registry as npmPublish is [secure] in my logs. So maybe this is something else on your side.

In each package.json I have

  "publishConfig": {
    "registry": "https://npm.pkg.github.com",
    "access": "restricted"
  },

@daniel-clover
Copy link

daniel-clover commented Aug 31, 2023 via email

@ruscon
Copy link
Contributor

ruscon commented Aug 31, 2023

@daniel-clover ps.
fix

"commitMessage": "chore(release): ${nextRelease.gitTag} [skip ci]\\n\\n${nextRelease.notes}",

to

"commitMessage": "chore(release): ${nextRelease.gitTag} [skip ci]\n\n${nextRelease.notes}",

@daniel-clover
Copy link

daniel-clover commented Aug 31, 2023 via email

@ruscon
Copy link
Contributor

ruscon commented Aug 31, 2023

@daniel-clover try to copy options from .nxreleaserc.json to concrete project.json

something like this

    "semantic-release": {
      "executor": "@theunderscorer/nx-semantic-release:semantic-release"
      "options": {
        "github": true,
        "changelog": false,
        "npm": true,
        "buildTarget": "nx-js:build",
        "outputPath": "dist/libs/nx/js",
        "tagFormat": "${PROJECT_NAME}-v${VERSION}"
      }
    }

change nx-js to your project name everywhere

@erwinokken
Copy link

erwinokken commented Nov 1, 2023

@daniel-clover try to copy options from .nxreleaserc.json to concrete project.json

something like this

    "semantic-release": {
      "executor": "@theunderscorer/nx-semantic-release:semantic-release"
      "options": {
        "github": true,
        "changelog": false,
        "npm": true,
        "buildTarget": "nx-js:build",
        "outputPath": "dist/libs/nx/js",
        "tagFormat": "${PROJECT_NAME}-v${VERSION}"
      }
    }

change nx-js to your project name everywhere

I can confirm that this works.

Before I had this configuration in the global .nxreleaserc.json:

"buildTarget": "${PROJECT_NAME}:build",
"outputPath": "dist/${PROJECT_DIR}",

I updated this to use the specific project.json files.

"options": {
	"buildTarget": "projectname:build",
	"outputPath": "dist/libs/projectname"
}

The error is misleading and an explicit warning/errorcould fix this.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 3 days.

@github-actions github-actions bot added the Stale label Dec 29, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants