Hello,
I’m using semantic-release to automatically create new releases after updating CHANGELOG.md
and I would like to run some jobs when the tag is pushed
- Merge a contribution in the
master
branch - The CI run the
build
andrelease
stages against themaster
branch-
semantic-release
updateCHANGELOG.md
and add a commit with the subject containingchore(release): X.Y.Z [skip ci]
-
semantic-release
create a tag with the new version -
semantic-release
create the new release in gitlab
-
- What are you seeing, and how does that differ from what you expect to see?
The pipeline for the tag is Skipped
-
What version are you on? Are you using self-managed or GitLab.com?
-
GitLab (Hint:
/help
):13.9.4-ee (fb7eeedfaf4)
self hosted -
Runner (Hint:
/admin/runners
):14.2.0
-
GitLab (Hint:
-
Add the CI configuration from
.gitlab-ci.yml
and other configuration if relevant (e.g. docker-compose.yml)
gitlab-ci.yml
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
###############################################################################
# Define stages and global variables
###############################################################################
stages:
- lint
- build
- release
variables:
DOCKER_DRIVER: overlay2
###############################################################################
# `lint` stage: `commitlint`
###############################################################################
commitlint:
stage: lint
rules:
- if: $CI_COMMIT_BRANCH
image: 'hub.eole.education/eole/commitlint:latest'
before_script:
# Add `upstream` remote to get access to `upstream/${CI_DEFAULT_BRANCH}`
- "git remote show upstream 2> /dev/null || git remote add upstream ${CI_REPOSITORY_URL}"
- 'git fetch --all'
after_script:
# Remove `upstream` to avoid caching `CI_JOB_TOKEN`
- "git remote remove upstream"
script:
# Set default commit hashes for `--from` and `--to`
- 'export COMMITLINT_FROM="$(git merge-base upstream/${CI_DEFAULT_BRANCH} HEAD)"'
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
# Run `commitlint`
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'
###############################################################################
# `build` stage: `*-docker-build`
###############################################################################
# Suffix all jobs to avoid conflict with other jobs names
foo-docker-build: {extends: '.build-docker-image'}
bar-docker-build: {extends: '.build-docker-image'}
# Define `build_docker_image` template used by `*-docker-build` jobs
.build-docker-image:
stage: build
rules:
- if: $CI_COMMIT_BRANCH
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
before_script:
- export NAME=${CI_JOB_NAME%-docker-build}
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile $CI_PROJECT_DIR/Dockerfile.${NAME} --destination ${CI_REGISTRY_IMAGE}/${NAME}:git-${CI_COMMIT_SHORT_SHA}
###############################################################################
# `release` stage: `semantic-release`, `*-docker-tag`
###############################################################################
semantic-release:
stage: release
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
image: 'hub.eole.education/eole/semantic-release:latest'
script:
- 'semantic-release'
# Suffix all jobs to avoid conflict with other jobs names
foo-docker-tag: {extends: '.tag-docker-image'}
bar-docker-tag: {extends: '.tag-docker-image'}
# Define `tag_docker_image` template used by `*-docker-tag` jobs
.tag-docker-image:
stage: release
rules:
# Only for protected release tags
- if: $CI_COMMIT_TAG =~ /^release\// && $CI_COMMIT_REF_PROTECTED
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
variables:
GIT_STRATEGY: none
before_script:
- export NAME=${CI_JOB_NAME%-docker-tag}
- export RELEASE=${CI_COMMIT_TAG#release/}
script:
- crane auth login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- crane tag ${CI_REGISTRY_IMAGE}/${NAME}:git-${CI_COMMIT_SHORT_SHA} ${RELEASE}
- crane tag ${CI_REGISTRY_IMAGE}/${NAME}:git-${CI_COMMIT_SHORT_SHA} latest
- What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
It’s the same as the old post Run pipeline on tag after ci skip (maven release) which don’t have a solution.
Does someone have a hint on how to do?
Regards.