Skip to content

Commit

Permalink
Use version correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
gavlyukovskiy committed Dec 2, 2023
1 parent 9be9beb commit 0de672f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/on-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,35 @@ jobs:
java-version: 17
cache: 'gradle'

- id: get-snapshot-version
name: Generate snapshot version
shell: bash
run: |
version=$(git describe --tag --abbrev=0 | cut -c 2-)
regex="^([0-9]+).([0-9]+).([0-9]+)$"
if [[ $version =~ $regex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
patch="${BASH_REMATCH[3]}"
patch=$(($patch + 1))
snapshot_version="${major}.${minor}.${patch}"
if ! [[ $snapshot_version =~ $regex ]]; then
echo "SNAPSHOT version $snapshot_version is not a valid SemVer"
exit 1
fi
echo "${snapshot_version}-SNAPSHOT"
echo "snapshot-version=${snapshot_version}-SNAPSHOT" >> $GITHUB_OUTPUT
else
echo "Version $version is not a valid SemVer"
exit 1
fi
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew -Pversion=${{ steps.get-snapshot-version.outputs.snapshot-version }} build

- name: Upload snapshot artifacts to Sonatype
id: upload_snapshot_artifacts
Expand All @@ -32,4 +59,4 @@ jobs:
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
run: ./gradlew -Pversion=${{ steps.get-snapshot-version.outputs.snapshot-version }} publishToSonatype closeAndReleaseSonatypeStagingRepository
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "com.github.gavlyukovskiy"
version = "0.1.0-SNAPSHOT"
version = version.takeUnless { it == "unspecified" } ?: "0.1.0-SNAPSHOT"

val sonatypeUser: String? = project.properties["sonatype_user"]?.toString()
?: System.getenv("SONATYPE_USER")
Expand Down

0 comments on commit 0de672f

Please sign in to comment.