I'm in the process of migrating my projects from GitHub.com to a self-hosted GitLab CE instance. I had previously set up a GitHub Actions pipeline to publish the application when a new release was cut from a tag. That is, when I went to github.com/<organization>/<project>/tags and edited a tag to publish a release, the following *-workflow.yml script snippet would trigger my desired action:
on:
release:
types: [created]
What is the equivalent of that on GitLab CI/CD (.gitlab-ci.yml)? I searched all over the GitLab docs and auxiliary websites like gitlab.reddit.com and Stack Overflow, but couldn't find any way to do that. To be clear, the steps for converting a tag into a bona-fide release in GitLab are as follows:
<GitLab CE>/<group>/<project>/-/releases/newI'd like GitLab to execute my script immediately upon step 4 above.
I'm not sure if Gitlab has a similar feature, or at least I couldn't find anything in the documentation.
A workaround could be creating a release automatically in the CI pipeline after creating a tag. So whenever a tag is created from a specific branch, the CI pipeline will create a release. You can also control the creation of the Release using the $CI_COMMIT_TAG value.
release:
stage: release
script:
- echo "Create release when a tag is created"
rules:
- if: '$CI_COMMIT_TAG' # Any tag is created
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+\-release/' # A specific tag with 'vX.Y.Z-release' pattern is created
release:
name: 'My awesome release'
tag_name: '$CI_COMMIT_TAG'
For more information about creating a new Release using the CI pipeline you can read this page from the documentation:
Create release from GitLab CI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With