Skip to content
Snippets Groups Projects
Semantic-release.yaml 1.94 KiB
Newer Older
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# Produce a new release using semantic versionning scheme when new
# commits arrive on the production branch.
#
# USAGE
# =====
#
# include:
#   - project: EOLE/infra/ci-tools
#     ref: stable
#     file: /templates/Release/Semantic-release.yaml
#
# REQUIREMENTS
# ============
#
# - A `release` stage must be present in your pipeline
# - One of the `semantic-release` configuration file must be present
#   - `release.config.js`
#   - `.releaserc`
#   - `.releaserc.js`
#   - `.releaserc.json`
#   - `.releaserc.yaml`
#   - `.releaserc.yml`
# - an access token named `GITLAB_TOKEN` with
#   - `api`
#   - `read_repository`
#   - `write_repository`
# - The variable `$STABLE_BRANCH` defined
#
# OPTIONAL VARIABLES
# ==================
#
# - `SEMANTIC_RELEASE_IMAGE`: name of the `semantic-release` docker
#   image to use
#
# SEE ALSO
# ========
#
# - Semantic release software: https://github.com/semantic-release/semantic-release/
# - Commitlint: https://github.com/conventional-changelog/commitlint/
#
# IMPORTANT NOTE
# ==============
#
# We can't merge rules with `!reference` until we switch to Gitlab >= 14.3
# https://gitlab.com/gitlab-org/gitlab/-/issues/322992

.on-stable-with-semantic-release-config:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
      when: never
    # Exclude semantic-release commits on $STABLE_BRANCH
    - if: $CI_COMMIT_BRANCH == $STABLE_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
      when: never
    - if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
      exists:
        - release.config.js
        - .releaserc
        - .releaserc.yaml
        - .releaserc.yml
        - .releaserc.json
        - .releaserc.js
      when: on_success

semantic-release:
  stage: release
  extends: .on-stable-with-semantic-release-config
  image: "$SEMANTIC_RELEASE_IMAGE"
  variables:
    SEMANTIC_RELEASE_IMAGE: 'hub.eole.education/eole/semantic-release-gitlab:latest'