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

Pre-release is tagged with latest tag #10

Open
devdanco opened this issue Sep 14, 2023 · 5 comments
Open

Pre-release is tagged with latest tag #10

devdanco opened this issue Sep 14, 2023 · 5 comments

Comments

@devdanco
Copy link

Hi, I'm a big fan of this library because it really helps me in configuring a monorepo with semantic release. However, I've encountered a single issue related to prereleases. In my release configuration, I've specified "beta" as a prerelease, but when I trigger a prerelease, the package gets released with the "latest" tag instead of "beta." Do you happen to know how I can set this up correctly, or is this possibly an issue specific to semantic release? Interestingly, I have a standard repository with a similar configuration, and I don't encounter this problem there. Thank you for your help!

Here it is how I specify branches in config:
branches: ['main', {name: 'beta', prerelease: true}]

@nivekcode
Copy link
Owner

Hmm. The library just uses multiple release configs. Did you add the config to the top-level release config or to a release config of a library?

@devdanco
Copy link
Author

@kreuzerk I just use npx nx g nx-release:configure and then in the root I changed branches: ['main'] to branches: ['main', {name: 'beta', prerelease: true}]

I have lib called foundation and inside project.json I have this
"release": { "executor": "nx-release:build-update-publish", "options": { "libName": "foundation" } }

When I created branch beta and pushed to github it released the correct beta version of the lib but the tag was latest and not beta
This is output from github:

npm notice === Tarball Details === 
npm notice name:          @mononxtest/foundation                  
npm notice version:       1.2.0-beta.1                              
npm notice filename:      mononxtest-foundation-1.2.0-beta.1.tgz    
npm notice package size:  844 B                                   
npm notice unpacked size: 1.3 kB                    
npm notice total files:   8                                       
npm notice 
npm notice Publishing to https://registry.npmjs.org/ with tag latest and public access

@SchettlerKoehler
Copy link

Hi @kreuzerk and @devdanco,
we have a similar issue which we traced back to this issue: When we are specifying a channel in the release config like it is documented here https://github.com/semantic-release/semantic-release/blob/master/docs/usage/workflow-configuration.md#channel the tag is also always latest.

It looks as if the issue is in https://github.com/kreuzerk/nx-release/blob/main/libs/nx-release/src/executors/npm-publish/executor.ts#L14 because npm publish is called without the --tag option (https://docs.npmjs.com/cli/v10/commands/npm-publish#tag)

Any updates on the issue?

@dpotoole
Copy link

dpotoole commented Apr 10, 2024

@devdanco @SchettlerKoehler

If you're on Nx 18, you can take advantage of Nx Release for the publishing step which allows you to specify a tag. I ended up tweaking the @semantic-release/exec plugin section of release config like so:

[
      '@semantic-release/exec',
      {
        // keep the release target on your publishable projects but update each project.json to use `update-version` executor instead of `build-update-publish` and then use `nx release` to publish
        prepareCmd: `VERSION=\${nextRelease.version} npx nx run-many -t release && npx nx release publish --tag=\${nextRelease.channel}  --dry-run`,
],

I also had to make a few changes to nx,json. I had to configure the release section and add the following to targetDefaults. Your configuration may differ based on how your workspace is structured.

"nx-release-publish": {
      "dependsOn": ["build"],
      "options": {
        "packageRoot": "{workspaceRoot}/dist/{projectRoot}"
      }
    }

Still have some more testing to do but so far it looks pretty good.

@markuczy
Copy link

markuczy commented Nov 29, 2024

@nivekcode I've prepared a Pull Request that could help resolving the issue that people in this thread encountered. Hope it helps :) #18

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

No branches or pull requests

5 participants