semantic-release: How do you publish a repository that doesn't output a node.js module?
Current behavior
When attempting to publish a javascript project that outputs a bundle instead of a node package, the script requires an NPM token.
Basically I want to publish some built assets to a cdn, but semantic-release is requiring an NPM token.
Expected behavior
The build shouldn’t require an NPM token.
Environment
- semantic-release version: 15.0.2
- CI environment: CircleCI
- Plugins used: @semantic-release/exec, condition-circle, @semantic-release/github
- semantic-release configuration: .releaserc.json
{
"release": {
"publish": [
{
"path": "@semantic-release/exec",
"cmd": "echo ${nextRelease.version}.min.js"
},
{
"path": "@semantic-release/github"
}
],
"verifyConditions": "condition-circle"
}
}
- CI logs:
Current behavior
When attempting to publish a javascript project that outputs a bundle instead of a node package, the script requires an NPM token.
Expected behavior
The build shouldn’t require an NPM token.
Environment
- semantic-release version: 15.0.2
- CI environment: CircleCI
- Plugins used: @semantic-release/exec, condition-circle
- semantic-release configuration: .releaserc.json
{
"release": {
"publish": [
{
"path": "@semantic-release/exec",
"cmd": "echo ${nextRelease.version}.min.js"
},
{
"path": "@semantic-release/github"
}
],
"verifyConditions": "condition-circle"
}
}
- CI logs:
circleci build -e GH_TOKEN=<redacted> -e NPM_TOKEN=000000000000-0000-0000-000000000000
INFO: There's a newer version of CircleCI build-agent available. Run 'circleci update' for update
====>> Spin up Environment
Build-agent version 0.0.4710-44beb0a (2018-02-27T20:05:34+0000)
Starting container circleci/node:8.9.4
using image circleci/node@sha256:b0fa2a8158710ba49cf4f42fe5b31715694026517207ff141fffb6ab45b24ab0
Using build environment variables:
BASH_ENV=/tmp/.bash_env-localbuild-1520892408
CI=true
CIRCLECI=true
CIRCLE_BRANCH=master
CIRCLE_BUILD_NUM=
CIRCLE_JOB=build
CIRCLE_NODE_INDEX=0
CIRCLE_NODE_TOTAL=1
CIRCLE_REPOSITORY_URL=<redacted>
CIRCLE_SHA1=3a78a4324a14578eaf523887d7f35e5178b3f395
CIRCLE_SHELL_ENV=/tmp/.bash_env-localbuild-1520892408
CIRCLE_WORKING_DIRECTORY=~/repo
====>> Checkout code
#!/bin/sh
mkdir -p /home/circleci/repo && cp -r /tmp/_circleci_local_build_repo/. /home/circleci/repo
====>> Restoring Cache
Error: Skipping cache - error checking storage: not supported
Step failed
====>> Run semantic-release
#!/bin/bash -eo pipefail
sudo npm i -g semantic-release@15.0.2
/usr/local/bin/semantic-release -> /usr/local/lib/node_modules/semantic-release/bin/semantic-release.js
+ semantic-release@15.0.2
added 387 packages in 10.944s
====>> Run semantic-release
#!/bin/bash -eo pipefail
semantic-release
[Semantic release]: Running semantic-release version 15.0.2
Username for 'https://<redacted>': [Semantic release]: Load plugin verifyConditions from @semantic-release/npm
[Semantic release]: Load plugin verifyConditions from @semantic-release/github
[Semantic release]: Load plugin analyzeCommits from @semantic-release/commit-analyzer
[Semantic release]: Load plugin generateNotes from @semantic-release/release-notes-generator
[Semantic release]: Load plugin prepare from @semantic-release/npm
[Semantic release]: Load plugin publish from @semantic-release/npm
[Semantic release]: Load plugin publish from @semantic-release/github
[Semantic release]: Load plugin success from @semantic-release/github
[Semantic release]: Load plugin fail from @semantic-release/github
[Semantic release]: Run automated release from branch master
[Semantic release]: Call plugin verify-conditions
[Semantic release]: Verify authentication for registry https://registry.npmjs.org/
[Semantic release]: Wrote NPM_TOKEN to .npmrc.
[Semantic release]: Verify GitHub authentication
DEPRECATED: protocol option is no longer supported
DEPRECATED: host option is no longer supported
DEPRECATED: port option is no longer supported
DEPRECATED: pathPrefix option is no longer supported
[Semantic release]: Verify GitHub authentication
DEPRECATED: protocol option is no longer supported
DEPRECATED: host option is no longer supported
DEPRECATED: port option is no longer supported
DEPRECATED: pathPrefix option is no longer supported
[Semantic release]: EINVALIDGHTOKEN Invalid GitHub token.
The GitHub token (https://github.com/semantic-release/github/blob/master/README.md#github-authentication) configured in the GH_TOKEN or GITHUB_TOKEN environment variable must be a valid personnal token (https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) allowing to push to the repository <redacted>.
Please make sure to set the GH_TOKEN or GITHUB_TOKEN environment variable in your CI with the exact value of the GitHub personnal token.
[Semantic release]: EINVALIDNPMTOKEN Invalid npm token.
The npm token (https://github.com/semantic-release/npm/blob/master/README.md#npm-registry-authentication) configured in the NPM_TOKEN environment variable must be a valid token (https://docs.npmjs.com/getting-started/working_with_tokens) allowing to publish to the registry https://registry.npmjs.org/.
If you are using Two-Factor Authentication, make configure the auth-only level (https://docs.npmjs.com/getting-started/using-two-factor-authentication#levels-of-authentication) is supported. semantic-release cannot publish with the default auth-and-writes level.
Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.
[Semantic release]: EINVALIDGHTOKEN Invalid GitHub token.
The GitHub token (https://github.com/semantic-release/github/blob/master/README.md#github-authentication) configured in the GH_TOKEN or GITHUB_TOKEN environment variable must be a valid personnal token (https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) allowing to push to the repository <redacted>.
Please make sure to set the GH_TOKEN or GITHUB_TOKEN environment variable in your CI with the exact value of the GitHub personnal token.
{ AggregateError:
SemanticReleaseError: Invalid npm token.
at module.exports (/usr/local/lib/node_modules/semantic-release/node_modules/@semantic-release/npm/lib/get-error.js:6:10)
at module.exports (/usr/local/lib/node_modules/semantic-release/node_modules/@semantic-release/npm/lib/verify-auth.js:23:33)
at <anonymous>
SemanticReleaseError: Invalid GitHub token.
at module.exports (/usr/local/lib/node_modules/semantic-release/node_modules/@semantic-release/github/lib/get-error.js:6:10)
at module.exports (/usr/local/lib/node_modules/semantic-release/node_modules/@semantic-release/github/lib/verify.js:86:21)
at <anonymous>
at Object.verifyConditions (/usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:52:45)
at <anonymous> name: 'AggregateError' }
Error: Exited with code 1
Step failed
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (8 by maintainers)
I’ll submit some pull requests per each repo vs trying to delineate what can be improved further. Thanks again! Love the tooling.
Just want to say thank you for your help. At the end of the day, it came down to to major roadblocks:
npmPublish: false
at top level in your release configurationsemantic-release/github
plugin correctlyAt the end of the day it was in regards to my previous comment:
Here’s the .releaserc.json configuration that I used:
Feedback
I found a few things that I may end up sending a pull request for:
"npmPublish: false
) or setting it for every single plugin config.However, I find that this is pretty buried and should probably be surfaced somewhere else outside of just the semanti-release-cli
The npm plugin is used for the
publish
, theverifyConditons
and theprepare
step. You need to setnpmPublish
in the 3 of them. Or for more simplicity you can setnpmPublish
directly in therelease
object.Even if you don’t publish on npm, you still need to configure
GH_TOKEN
to publish on GitHub. This is why you get an error message.I think this FAQ should answer your exact question.
Also you shouldn’t use
condition-circle
as CI related verify plugins are not required since several version of semantic-release.