GitLab CI automatic release
GitLab currently does not provide a straight forward way of creating releases for a repository as part of the GitLab CI. At the time of writing, there is an open issue discussing how to incorporate releases into GitLab CI. In the meantime the Releases API provides a RESTful way of accomplishing this.
To create a release using GitLab CI you first need an access token. These can be generated in your
GitLab account. Once you
have your access token assign it as
an environment variable as part of the project’s CI/CD. The environment variable releasetoken
is used in
the example below.
Below is an example of how to set this up in .gitlab-ci.yml
. This POST
creates a release for tagged versions. The Releases API can also
be use to modify a release, which may be useful for attaching a binary generated by the CI pipeline.