Compare git tag without build number
What does this MR do?
Change the tag version
job so that it ignores the build number when comparing the git tag, like v1.2.3+4
without the last changelog entry, like ## v1.2.3
.
The build number is also removed from the image tag, otherwise docker tag
throws invalid reference format
.
Shell parameter expansion ${parameter/pattern/string}
is used to remove the build number from the CI_COMMIT_TAG
:
% for CI_COMMIT_TAG in 1.2.34 1.2.34+1 1.2.34-xyz 1.2.34-xyz+1 1.2.34-xyz+1+2 1.2.34-xyz+1-abc; do echo ${CI_COMMIT_TAG/+*/}; done
1.2.34
1.2.34
1.2.34-xyz
1.2.34-xyz
1.2.34-xyz
1.2.34-xyz
Manual tests:
% head -n 5 CHANGELOG.md
# Gemnasium analyzer changelog
## v2.26.0
- Update Node to version 14 (LTS) and Alpine to 3.12 (!166)
for CI_COMMIT_TAG in v2.25.0 v2.26.0 v2.26.0+1; do
RELEASE=${CI_COMMIT_TAG/+*/}; IMAGE_TAG=${RELEASE/v/}; echo TAG: $CI_COMMIT_TAG IMAGE_TAG: $IMAGE_TAG; echo "Checking that $RELEASE is last in the changelog"; test "$(grep -m 1 '^## v' CHANGELOG.md)" = "## $RELEASE" && echo OK || echo FAIL
done
TAG: v2.25.0 IMAGE_TAG: 2.25.0
Checking that v2.25.0 is last in the changelog
FAIL
TAG: v2.26.0 IMAGE_TAG: 2.26.0
Checking that v2.26.0 is last in the changelog
OK
TAG: v2.26.0+1 IMAGE_TAG: 2.26.0
Checking that v2.26.0 is last in the changelog
OK
What are the relevant issue numbers?
gitlab-org/gitlab#284643 (closed)
Does this MR meet the acceptance criteria?
-
Tests added for this feature/bug (manual tests) - successful pipeline for v2.26.0: https://gitlab.com/fcatteau/gemnasium-pipeline/-/pipelines/240921410
- successful pipeline for v2.26.0+1: https://gitlab.com/fcatteau/gemnasium-pipeline/-/pipelines/240920607
- failing pipeline for v2.26.0+2 (doesn't match changelog): https://gitlab.com/fcatteau/gemnasium-pipeline/-/pipelines/240927388
Edited by Fabien Catteau