Skip to content

Commit

Permalink
chore(ci): appen buildnumber while publishing snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
osoykan committed Nov 28, 2024
1 parent a19dbb9 commit 8d2b855
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gradle-publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
run: gradle publish --parallel
env:
SNAPSHOT: true
BUILD_NUMBER: ${{ github.run_number }}
gpg_private_key: ${{ secrets.gpg_private_key }}
gpg_passphrase: ${{ secrets.gpg_passphrase }}
nexus_username: ${{ secrets.nexus_username }}
Expand Down
10 changes: 1 addition & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
java
}
group = "com.trendyol"
version = version()
version = CI.version(project)

allprojects {
extra.set("dokka.outputDirectory", rootDir.resolve("docs"))
Expand Down Expand Up @@ -157,11 +157,3 @@ tasks.withType<DokkaMultiModuleTask>().configureEach {
outputDirectory.set(file(rootDir.resolve("docs/source")))
}

fun version(): String = when {
System.getenv("SNAPSHOT") != null -> {
println("SNAPSHOT: ${System.getenv("SNAPSHOT")}")
project.properties["snapshot"].toString()
}

else -> project.properties["version"].toString()
}
20 changes: 20 additions & 0 deletions buildSrc/src/main/kotlin/CI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import org.gradle.api.Project

object CI {
private val isSnapshot: Boolean
get() = System.getenv("SNAPSHOT") != null && System.getenv("SNAPSHOT") == "true"

private val Project.snapshotBase: String
get() = properties["snapshot"].toString()

private val Project.releaseVersion: String
get() = properties["version"].toString()

private val buildNumber: String
get() = System.getenv("BUILD_NUMBER") ?: "0"

fun version(project: Project): String = when {
isSnapshot -> "${project.snapshotBase}.${buildNumber}-SNAPSHOT"
else -> project.properties["version"].toString()
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ projectDescription=The easiest way of e2e testing in Kotlin
projectUrl=https://github.com/Trendyol/stove
licenceUrl=https://github.com/Trendyol/stove/blob/master/LICENCE
licence=Apache-2.0 license
snapshot=1.0.0-SNAPSHOT
snapshot=1.0.0
version=0.14.2


0 comments on commit 8d2b855

Please sign in to comment.