Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

Commit 1fd0bdd

Browse files
ci: forbid the publication of a version already released (#8)
Refs: #7
1 parent d3d1f48 commit 1fd0bdd

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

.github/scripts/check_version.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
tag=$1
4+
echo "Input tag: '$tag'"
5+
6+
version=`grep "^version" gradle.properties | cut -d= -f2 | tr -d "[:space:]"`
7+
echo "Version in 'gradle.properties' file: '$version'"
8+
9+
if [ "$tag" != "" ]; then
10+
if [ "$tag" != "$version" ]; then
11+
echo "ERROR: the tag '$tag' is different from the version '$version' in the 'gradle.properties' file"
12+
exit 1
13+
fi
14+
fi
15+
16+
echo "Fetch tags..."
17+
git fetch --tags
18+
19+
if [ $(git tag -l "$version") ]; then
20+
echo "ERROR: version '$version' has already been released"
21+
exit 1
22+
fi

.github/workflows/java-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
2626
gpg --pinentry-mode loopback --passphrase "${{ secrets.OSSRH_GPG_SECRET_PASSWORD }}" --export-secret-key 568FD16F857171A0EC6D2C40742C84722FD2B235 > ~/.gradle/maven-central.gpg
2727
gpg --list-secret-keys --keyid-format LONG
28+
- name: Check version
29+
working-directory: .
30+
run: ./.github/scripts/check_version.sh
2831
- name: Build and Publish
2932
working-directory: .
3033
run: ./gradlew build test publish --info --stacktrace

.github/workflows/java-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
2626
gpg --pinentry-mode loopback --passphrase "${{ secrets.OSSRH_GPG_SECRET_PASSWORD }}" --export-secret-key 568FD16F857171A0EC6D2C40742C84722FD2B235 > ~/.gradle/maven-central.gpg
2727
gpg --list-secret-keys --keyid-format LONG
28+
- name: Check version
29+
working-directory: .
30+
run: ./.github/scripts/check_version.sh $(echo "${{ github.ref }}" | sed -e "s,^refs/tags/,,")
2831
- name: Build and Publish
2932
working-directory: .
3033
run: |

.github/workflows/java-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
with:
1717
java-version: '8'
1818
distribution: 'adopt'
19+
- name: Check version
20+
working-directory: .
21+
run: ./.github/scripts/check_version.sh
1922
- name: Build and Test
2023
working-directory: .
2124
run: ./gradlew build test --info --stacktrace

0 commit comments

Comments
 (0)