Skip to content
README.md 2.08 KiB
Newer Older
# `semantic-release`
Ivan Artiukhov's avatar
Ivan Artiukhov committed

> A job to run [semantic-release][semantic-release], a automated release deployment tool
Ivan Artiukhov's avatar
Ivan Artiukhov committed

## Overview
Ivan Artiukhov's avatar
Ivan Artiukhov committed

The `semantic-release` component automates the entire package release workflow, including determining the next version number, generating release notes, and publishing the package.
Ivan Artiukhov's avatar
Ivan Artiukhov committed

It strictly follows the [Semantic Versioning] specification and communicates the impact of changes to consumers.
Ivan Artiukhov's avatar
Ivan Artiukhov committed

## Getting Started
Ivan Artiukhov's avatar
Ivan Artiukhov committed

Include the following in `.gitlab-ci.yml`:
Ivan Artiukhov's avatar
Ivan Artiukhov committed

```yaml
include:
  - component: "${CI_SERVER_HOST}/ci/component/semantic-release@<version>"
Ivan Artiukhov's avatar
Ivan Artiukhov committed

semantic-release:
  extends: .semantic-release
Ivan Artiukhov's avatar
Ivan Artiukhov committed
```

## Usage

### Configuration
Ivan Artiukhov's avatar
Ivan Artiukhov committed

`semantic-release` [configuration] expects both instructions of which _branches_ to run on and the _plugins_ to execute.
Often this is easily represented in a [.releaserc.yml][releaserc] file. The plugins will depend on the type of project
to deploy; `semantic-release` has many open-source [plugins][plugins] that implement the common deployment steps.
Ivan Artiukhov's avatar
Ivan Artiukhov committed

`npm install --package-lock-only` will need to be ran locally to generate the `package-lock.json` file for the installed tools.
Ivan Artiukhov's avatar
Ivan Artiukhov committed

### Recipes
Ivan Artiukhov's avatar
Ivan Artiukhov committed

#### NPM
Ivan Artiukhov's avatar
Ivan Artiukhov committed

When using the `@semantic-release/npm` plugin, publishing to GitLab Package Registry can be configured with the NPM
configuration:
Ivan Artiukhov's avatar
Ivan Artiukhov committed

```yaml
semantic-release:
  extends: .semantic-release
  variables:
    NPM_TOKEN: "${CI_JOB_TOKEN}"
  before_script:
    - npm config set -- "@${CI_PROJECT_ROOT_NAMESPACE}:registry"
      "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/"
    - npm config set -- "${CI_API_V4_URL#https?}/packages/npm/:_authToken" '\${NPM_JOB_TOKEN}'
```
Ivan Artiukhov's avatar
Ivan Artiukhov committed

[Semantic Versioning]: https://semver.org
[semantic-release]: https://github.com/semantic-release/semantic-release
[plugins]: https://github.com/semantic-release
[configuration]: https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration
[conventional-commits]: https://www.conventionalcommits.org/
[semantic-versioning]: http://semver.org/
[oci]: oci.md
[releaserc]: ../.releaserc.yaml
[image]: https://docs.gitlab.com/ee/ci/yaml/#image