I have a C# project and would like to add semantic versioning to it. So whenever I push to the main
branch I want to create a new release and autogenerate a new version number based on the commit types. I think semantic-release does the job very well since I'm already using commitlint with husky.
For reproduction:
- Create a new repository on Github
- Inside the repo create a new C# project (you may skip this step)
- Run
npm init -y
to setup npm - Follow https://commitlint.js.org/#/guides-local-setup to setup commitlint and husky
- Create a new personal access token for your account
- Add a new Github secret to your repository, name it
SEMANTIC_RELEASE
and add the access token as the value for it - Based on https://semantic-release.gitbook.io/semantic-release/usage/getting-started create a new Github workflow
.
name: Release
on:
push:
branches:
- `main`
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Install dependencies
run: npm install
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE }}
run: npx semantic-release
- After pushing it the workflow should fail with the following error message
[2:51:48 PM] [semantic-release] › ✔ Completed step "fail" of plugin "@semantic-release/github" An npm token (https://github.com/semantic-release/npm/blob/master/README.md#npm-registry-authentication) must be created and set in the NPM_TOKEN environment variable on your CI environment.
Please make sure to create an npm token (https://docs.npmjs.com/getting-started/working_with_tokens#how-to-create-new-tokens) and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.
AggregateError: SemanticReleaseError: No npm token specified. at module.exports (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/node_modules/@semantic-release/npm/lib/get-error.js:6:10) at module.exports (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/node_modules/@semantic-release/npm/lib/set-npmrc-auth.js:45:31) at module.exports (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/node_modules/@semantic-release/npm/lib/verify-auth.js:17:9) at verifyConditions (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/node_modules/@semantic-release/npm/index.js:36:13) at async validator (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/lib/plugins/normalize.js:34:24) at async /home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/lib/plugins/pipeline.js:37:34 at async Promise.all (index 0) at async next (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/node_modules/p-reduce/index.js:16:18) at /home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/lib/plugins/pipeline.js:54:11 at async Object.pluginsConf. [as verifyConditions] (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/lib/plugins/index.js:80:11) at async run (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/index.js:95:3) at async module.exports (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/index.js:260:22) at async module.exports (/home/runner/.npm/_npx/1561/lib/node_modules/semantic-release/cli.js:55:5) Error: Process completed with exit code 1.
I don't want to publish to the npm registry, it should just create a new release version.
Did I miss something or is semantic-release the wrong tool for my project?