Extend CI Templates to include semantic-release
Problem to solve
Semantic versioning and release notes are best practices for a release manager. Today, we cannot automatically increment versions or generate releases. This would be especially helpful as an extension of all CI Templates.
Intended users
User experience goal
As a developer, I want my CICD templates to auto-increment versions and generate releases.
Proposal
Integrate Semantic Release (https://semantic-release.gitbook.io/semantic-release/recipes/recipes/gitlab-ci), into CI templates.
gitlab/ci/templates/Releases/Semantic-Release.yml
stages:
- release
semantic-release:
image: node:12
stage: release
before_script:
- npm install -g semantic-release @semantic-release/gitlab @semantic-release/exec
- |
cat <<-EOF >> .releaserc.yml
---
verifyConditions:
- "@semantic-release/gitlab"
prepare: false
publish:
- "@semantic-release/gitlab"
success: false
fail: false
npmPublish: false
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/gitlab"
- - "@semantic-release/exec"
- prepareCmd: "set-version ${nextRelease.version}"
publishCmd: "publish-package"
EOF
script:
- semantic-release
only:
refs:
- master
- beta
- /^\d+.x$/
- /^\d+.\d+.x$/
This allows users to quickly bootstrap release streamline with semantic-release
, for example, they can include the template, like:
# .gitlab-ci.yml
include:
template: Releases/Semantic-Release.yml
test:
script: test
which starts creating releases according to https://www.conventionalcommits.org/en/v1.0.0-beta.2/. Changelogs are also automatically generated according to the commit messages. Users should start following the convention in order to effectively use semantic-release