Skip to content

Commit

Permalink
build: Use gradle-semver-plugin to calculate project version (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
usmansaleem authored Jul 5, 2024
1 parent f01e08f commit c6ec061
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/upload-dependency-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: temurin
Expand Down
12 changes: 9 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ import org.jreleaser.model.UpdateSection
plugins {
`java-library`
alias(libs.plugins.spotless)
alias(libs.plugins.jgitver)
alias(libs.plugins.gradle.semver)
alias(libs.plugins.jreleaser)
}

semver {
tagPrefix("v")
initialVersion("0.0.0")
findProperty("semver.overrideVersion")?.toString()?.let { overrideVersion(it) }
}

project.group = "info.usmans.tools"

version = semver.version // project version, also used for jreleaser

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
Expand Down Expand Up @@ -45,8 +53,6 @@ spotless {
kotlinGradle { ktfmt() }
}

jgitver { nonQualifierBranches = "main" }

tasks.register("printVersion") {
group = "Help"
description = "Prints the project version"
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ junit-jupiter = "5.10.2"
spotless = "6.25.0"
slf4j = "2.0.13"
bouncy-castle = "1.78.1"
jgitver = "0.10.0-rc03"
jreleaser = "1.13.1"
figure-gradle-semver = "1.10.0"

[libraries]
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
Expand All @@ -19,5 +19,5 @@ bcprov = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncy-cas

[plugins]
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
jgitver = { id = "fr.brouillard.oss.gradle.jgitver", version.ref = "jgitver" }
gradle-semver = { id = "com.figure.gradle.semver-plugin", version.ref = "figure-gradle-semver" }
jreleaser = { id = "org.jreleaser", version.ref = "jreleaser"}

0 comments on commit c6ec061

Please sign in to comment.