Automate routine work with releasing new versions.
Part of the @kira
bots family.
So, when the time to release comes our bot:
- calculates a new semantic version since the last tagged release,
- summarizes the release notes from these commits,
- creates a signed GitLab release,
- creates a changelog entry, commits it to the project,
- tags a new release with the newly calculated version number,
- optionally uploads new
docker
images to GitLab registry
Internally we use semantic-release
.
With multiple plugins.
Every commit is validated to be compatible to conventional-changelog
format (here's our format just for example):
/^(revert: )?(feat|fix|docs|refactor|chore)(\(.+\))?:.{1,50}refs #\d+/
However, we do not enforce any particular format with this project. You are free to choose any existing or create your own.
We also recommend to enforce this format in Gitlab's push rules.
In this case I won't be able to push incorrect commit messages:
» git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 692 bytes | 692.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: GitLab: Commit message does not follow the pattern '/^(revert: )?(feat|fix|docs|refactor|chore) ...'
It is recommended to use this bot as a part of your CI. There are two possible ways to release your software:
- On every push to
master
(we considermaster
branch protected by default) - Manually by setting up
manual
CI jobs
They are not required, but may help you:
- Invite
@kira-bot
to your project - All tags must be protected, only
@kira-bot
is allowed to create them master
branch must be protected, only@kira-bot
is allowed to push
You are required to set:
GITLAB_TOKEN
secret variable in CI configuration
You can also optionally set:
KIRA_RELEASE_SKIP_DOCKER
to'true'
, so yourdocker
image deploy will be skippedKIRA_INCLUDE_COMMENTS
one of['all', 'issue', 'mergeRequest', 'off']
values when and where to post a comment on release, default:'off'
KIRA_RELEASE_ASSETS
to any assets string, so it will upload these files to GitLab releaseKIRA_RELEASE_EXEC_CONFIG
string withjson
config to pass to@semantic-release/exec
. Related docs on why would you possibly need thisKIRA_RELEASE_REPLACE_CONFIG
string withjson
config of how to bump version numbers in a project definition file, example:KIRA_RELEASE_REPLACE_CONFIG='{ "project": "package.json", "from": "\"version\": \".*\"", "to": "\"version\": \"${nextRelease.version}\"" }'
KIRA_RELEASE_BRANCHES
to semantic release branches default:['master', 'main']
GITLAB_URL
to change the GitLab location, see semantic-release-gitlab docs, default:'https://gitlab.com'
Note: You might want to use $$
to escape $
char in several environments like GitLab CI configuration file
We use five ebv variables to publish pre-built containers into the registry.
Basically, this is ready to work with GitLab CI and GitLab Container registry,
but you can modify it to work with any registry / CI.
For example, we use GitHub Container Registry in this project's CI
(see .github/workflows/test.yml
).
Variables:
CI_REGISTRY
: what registry you use:registry.gitlab.com
,ghrc.io
, or any otherCI_REGISTRY_USER
: username to use for loginCI_JOB_TOKEN
: the token we use to auth, can be any token that your registry supportsCI_PROJECT_NAMESPACE
: organization name to use in image nameCI_PROJECT_NAME
: project name to use in image name
Copy-paste our .gitlab-ci.yml
file. And modify it to match your project.
Special thanks to:
semantic-release-gitlab-docker
which we used before creating our ownGitLab
+docker
release script