Skip to content

Commit 1333022

Browse files
committed
ci: fixed release stage tag parsing
1 parent 89be6a1 commit 1333022

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.gitlab-ci.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ conventional-commits-next-version-checking:
5656
script:
5757
# Get current version and latest tag.
5858
- CURRENT_VERSION=`grep '^version = "[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*"$' Cargo.toml | cut -d '"' -f 2`
59-
# If the latest tag is not a semantic version then conventional_commits_next_version will fail.
59+
# Get latest tag.
6060
- LATEST_TAG=`git describe --tags | cut -d '-' -f 1`
6161
- LATEST_TAG_HASH=`git rev-parse $LATEST_TAG`
62+
# Check latest tag is in semantic versioning.
63+
- LATEST_TAG_SEMANTIC_VERSIONING=`echo $LATEST_TAG | grep "^[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*$" | wc -l`
64+
- test $LATEST_TAG_SEMANTIC_VERSIONING -eq 1 || exit 1
6265
# Check current vs expected.
6366
- /usr/local/cargo/bin/conventional_commits_next_version --batch-commits --from-commit-hash $LATEST_TAG_HASH --from-version $LATEST_TAG --current-version $CURRENT_VERSION
6467
rules:
@@ -103,13 +106,19 @@ releasing:
103106
- apk add git
104107
script:
105108
- CURRENT_VERSION=`grep '^version = "[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*"$' Cargo.toml | cut -d '"' -f 2`
106-
- TAG_EXISTS=`git show-ref --tags -d | awk "/ refs\/tags\/$CURRENT_VERSION/" | wc -l`
109+
- TAG_EXISTS=`git tag -l | grep "^$CURRENT_VERSION$" | wc -l`
107110
# If the tag already exist then exit.
108111
- test $TAG_EXISTS -eq 1 && exit 0
109-
# Getting the release description.
110-
- LATEST_TAG_HASH=`git rev-parse $(git tag -l | sort -r | head -1)`
112+
# Get latest tag.
113+
- LATEST_TAG=`git describe --tags | cut -d '-' -f 1`
114+
- LATEST_TAG_HASH=`git rev-parse $LATEST_TAG`
115+
# Check latest tag is in semantic versioning.
116+
- LATEST_TAG_SEMANTIC_VERSIONING=`echo $LATEST_TAG | grep "^[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*$" | wc -l`
117+
- test $LATEST_TAG_SEMANTIC_VERSIONING -eq 1 || exit 1
118+
# Download clog.
111119
- wget https://github.com/clog-tool/clog-cli/releases/download/v0.9.3/clog-v0.9.3-x86_64-unknown-linux-musl.tar.gz
112120
- tar xvf clog-v0.9.3-x86_64-unknown-linux-musl.tar.gz
121+
# Generate the release description.
113122
- RELEASE_DESCRIPTION=`./clog --from $LATEST_TAG_HASH --link-style Gitlab --subtitle $CURRENT_VERSION | tail -n +2`
114123
# Create the new release.
115124
- release-cli create --name $CURRENT_VERSION --description "$RELEASE_DESCRIPTION" --tag-name $CURRENT_VERSION --ref $CI_COMMIT_SHA

0 commit comments

Comments
 (0)