Skip to content

Commit 8d2b855

Browse files
committed
chore(ci): appen buildnumber while publishing snapshot
1 parent a19dbb9 commit 8d2b855

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.github/workflows/gradle-publish-snapshot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
run: gradle publish --parallel
2929
env:
3030
SNAPSHOT: true
31+
BUILD_NUMBER: ${{ github.run_number }}
3132
gpg_private_key: ${{ secrets.gpg_private_key }}
3233
gpg_passphrase: ${{ secrets.gpg_passphrase }}
3334
nexus_username: ${{ secrets.nexus_username }}

build.gradle.kts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins {
1414
java
1515
}
1616
group = "com.trendyol"
17-
version = version()
17+
version = CI.version(project)
1818

1919
allprojects {
2020
extra.set("dokka.outputDirectory", rootDir.resolve("docs"))
@@ -157,11 +157,3 @@ tasks.withType<DokkaMultiModuleTask>().configureEach {
157157
outputDirectory.set(file(rootDir.resolve("docs/source")))
158158
}
159159

160-
fun version(): String = when {
161-
System.getenv("SNAPSHOT") != null -> {
162-
println("SNAPSHOT: ${System.getenv("SNAPSHOT")}")
163-
project.properties["snapshot"].toString()
164-
}
165-
166-
else -> project.properties["version"].toString()
167-
}

buildSrc/src/main/kotlin/CI.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import org.gradle.api.Project
2+
3+
object CI {
4+
private val isSnapshot: Boolean
5+
get() = System.getenv("SNAPSHOT") != null && System.getenv("SNAPSHOT") == "true"
6+
7+
private val Project.snapshotBase: String
8+
get() = properties["snapshot"].toString()
9+
10+
private val Project.releaseVersion: String
11+
get() = properties["version"].toString()
12+
13+
private val buildNumber: String
14+
get() = System.getenv("BUILD_NUMBER") ?: "0"
15+
16+
fun version(project: Project): String = when {
17+
isSnapshot -> "${project.snapshotBase}.${buildNumber}-SNAPSHOT"
18+
else -> project.properties["version"].toString()
19+
}
20+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ projectDescription=The easiest way of e2e testing in Kotlin
88
projectUrl=https://github.com/Trendyol/stove
99
licenceUrl=https://github.com/Trendyol/stove/blob/master/LICENCE
1010
licence=Apache-2.0 license
11-
snapshot=1.0.0-SNAPSHOT
11+
snapshot=1.0.0
1212
version=0.14.2
1313

1414

0 commit comments

Comments
 (0)