File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed
Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 2222 java-version : 17
2323 cache : ' gradle'
2424
25+ - id : get-snapshot-version
26+ name : Generate snapshot version
27+ shell : bash
28+ run : |
29+ version=$(git describe --tag --abbrev=0 | cut -c 2-)
30+ regex="^([0-9]+).([0-9]+).([0-9]+)$"
31+ if [[ $version =~ $regex ]]; then
32+ major="${BASH_REMATCH[1]}"
33+ minor="${BASH_REMATCH[2]}"
34+ patch="${BASH_REMATCH[3]}"
35+
36+ patch=$(($patch + 1))
37+
38+ snapshot_version="${major}.${minor}.${patch}"
39+
40+ if ! [[ $snapshot_version =~ $regex ]]; then
41+ echo "SNAPSHOT version $snapshot_version is not a valid SemVer"
42+ exit 1
43+ fi
44+
45+ echo "${snapshot_version}-SNAPSHOT"
46+ echo "snapshot-version=${snapshot_version}-SNAPSHOT" >> $GITHUB_OUTPUT
47+ else
48+ echo "Version $version is not a valid SemVer"
49+ exit 1
50+ fi
51+
2552 - name : Build with Gradle
26- run : ./gradlew build
53+ run : ./gradlew -Pversion=${{ steps.get-snapshot-version.outputs.snapshot-version }} build
2754
2855 - name : Upload snapshot artifacts to Sonatype
2956 id : upload_snapshot_artifacts
3259 SONATYPE_PASSWORD : ${{ secrets.SONATYPE_PASSWORD }}
3360 GPG_KEY : ${{ secrets.GPG_KEY }}
3461 GPG_PASSPHRASE : ${{ secrets.GPG_PASSPHRASE }}
35- run : ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
62+ run : ./gradlew -Pversion=${{ steps.get-snapshot-version.outputs.snapshot-version }} publishToSonatype closeAndReleaseSonatypeStagingRepository
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ plugins {
66}
77
88group = " com.github.gavlyukovskiy"
9- version = " 0.1.0-SNAPSHOT"
9+ version = version. takeUnless { it == " unspecified " } ? : " 0.1.0-SNAPSHOT"
1010
1111val sonatypeUser: String? = project.properties[" sonatype_user" ]?.toString()
1212 ? : System .getenv(" SONATYPE_USER" )
You can’t perform that action at this time.
0 commit comments