Skip to content

Commit 02601e0

Browse files
Add a step to the flow to validate the tag version
1 parent 3f3d8ea commit 02601e0

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ jobs:
2222
run: apt-get update && apt-get install -y git
2323
- name: Checkout repository
2424
uses: actions/checkout@v4
25+
- name: "Validate version tag doesn't exist"
26+
run: |
27+
VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2)
28+
TAG="v${VERSION}"
29+
if git ls-remote --tags origin | grep -q "refs/tags/${TAG}$"; then
30+
echo "============================================="
31+
echo "ERROR: Tag ${TAG} already exists!"
32+
echo ""
33+
echo "Please bump the version in gradle.properties"
34+
echo "============================================="
35+
exit 1
36+
fi
37+
echo "✓ Version ${VERSION} is valid (tag ${TAG} does not exist yet)"
2538
- name: "Gradle cache"
2639
uses: actions/cache@v4
2740
with:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ task tagRelease {
164164
grgit.push(refsOrSpecs: ["v$version"])
165165
}
166166
catch (RefAlreadyExistsException ignored) {
167-
throw new GradleException("Tag v$version already exists. Bump the version in gradle.properties before tagging again.")
167+
logger.warn("Tag v$version already exists.")
168168
}
169169
}
170170
}

0 commit comments

Comments
 (0)