semantic-release
AboutGitHubNeed Help?
master
master
  • README
  • Usage
    • Getting started
    • Installation
    • CI Configuration
    • Configuration
    • Plugins
    • Release Workflow configuration
    • Shareable configurations
  • Extending
    • Plugins
    • Shareable configuration
  • Recipes
    • CI configurations
      • CircleCI 2.0
      • Travis CI
      • GitLab CI
      • GitHub Actions
      • Jenkins CI
    • Git hosted services
      • Git authentication with SSH keys
    • Release Workflow
      • Publishing on distribution channels
      • Publishing maintenance releases
      • Publishing pre-releases
  • Developer guide
    • JavaScript API
    • Plugin development
    • Shareable configuration development
  • Support
    • Resources
    • Frequently Asked Questions
    • Troubleshooting
    • Node version requirement
    • Node Support Policy
    • Git version requirement
Powered by GitBook
On this page
  • Environment variables
  • npm provenance
  • Node project configuration
  • .gitlab-ci.yml configuration for Node projects
  • .gitlab-ci.yml configuration for all projects
  • package.json configuration
Edit on GitHub
  1. Recipes
  2. CI configurations

GitLab CI

PreviousTravis CINextGitHub Actions

Last updated 12 months ago

Environment variables

The environment variables can be configured with .

Note: Make sure to configure your release branch as in order for the CI/CD build to access the protected variables.

npm provenance

Since GitLab CI is a for , it is recommended to enable this to increase supply-chain security for your npm packages. Find more detail about configuring npm to publish with provenance through semantic-release .

Node project configuration

GitLab CI supports allowing to test on multiple Node versions and publishing a release only when all test pass.

Note: The publish pipeline must run a .

.gitlab-ci.yml configuration for Node projects

This example is a minimal configuration for semantic-release with a build running Node 10 and 12. See for additional configuration options.

Note: Thesemantic-release execution command varies depending on whether you are using a or semantic-release installation.

# The release pipeline will run only if all jobs in the test pipeline are successful
stages:
  - test
  - release

before_script:
  - npm install

node:10:
  image: node:10
  stage: test
  script:
    - npm test

node:12:
  image: node:12
  stage: test
  script:
    - npm test

publish:
  image: node:12
  stage: release
  script:
    - npx semantic-release

.gitlab-ci.yml configuration for all projects

# The release pipeline will run only on the master/main branch a commit is triggered
stages:
  - release

release:
  image: node:10-buster-slim
  stage: release
  before_script:
    - apt-get update && apt-get install -y --no-install-recommends git-core ca-certificates
    - npm install -g semantic-release @semantic-release/gitlab
  script:
    - semantic-release
  rules:
    - if: $CI_COMMIT_BRANCH == "master" # or main

release:
  image: node:12-buster-slim
  stage: release
  before_script:
    - apt-get update && apt-get install -y --no-install-recommends git-core ca-certificates
    - npm install -g semantic-release @semantic-release/gitlab
  script:
    - semantic-release
  rules:
    - if: $CI_COMMIT_BRANCH == "master" # or main

package.json configuration

{
  "devDependencies": {
    "semantic-release": "^15.0.0"
  }
}

This example is a minimal configuration for semantic-release with a build running Node 10 and 12. See for additional configuration options.

Note: Thesemantic-release execution command varies depending if you are using a or semantic-release installation.

A package.json is required only for semantic-release installation.

GitLab CI - Configuration of your jobs with .gitlab-ci.yml
Protected variables
protected
supported provider
npm provenance
in the documentation for our npm plugin
Pipelines
Node version that meets our version requirement
GitLab CI - Configuration of your jobs with .gitlab-ci.yml
Authentication
local
global
local
global
local