An example project that uses semantic-release to automate the publishing of NPM packages to GitLab's Package Registry.
See the auto-generated releases on the Releases page and the auto-published NPM packages on the Packages page.
A step-by-step guide can be found in GitLab's CI/CD examples documentation.
As part of publishing a package, semantic-release bumps the version in package.json
. To allow it to commit this change and push it back to GitLab, the pipeline requires a custom environment variable named GITLAB_TOKEN
, a project access token with api
scope. This token can be generated by navigating to Project > Settings > Access Tokens. Be sure to mask this variable (otherwise it may be printed in plaintext in the job output).
To use this example module in another project, add the following to the project's .npmrc
:
@gitlab-examples:registry=https://gitlab.com/api/v4/packages/npm/
Or, if using Yarn, add this to the project's .yarnrc
"@gitlab-examples:registry" "https://gitlab.com/api/v4/packages/npm/"
Then, install the package:
npm install --save @gitlab-examples/semantic-release-npm
or:
yarn add @gitlab-examples/semantic-release-npm