File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1
1
plugins {
2
2
kotlin(" jvm" ) version " 2.0.21"
3
3
kotlin(" plugin.serialization" ) version " 2.1.0"
4
+ `maven- publish`
4
5
}
5
6
6
7
group = " org.ctrlhub"
@@ -23,6 +24,42 @@ dependencies {
23
24
testImplementation(libs.ktor.client.mock)
24
25
}
25
26
27
+ fun Project.getGitTag (): String {
28
+ return try {
29
+ val process = ProcessBuilder (" git" , " describe" , " --tags" , " --abbrev=0" )
30
+ .redirectErrorStream(true )
31
+ .start()
32
+ process.waitFor(10 , TimeUnit .SECONDS )
33
+ process.inputStream.bufferedReader().readText().trim()
34
+ } catch (e: Exception ) {
35
+ " 0.0.0" // Default version if no tags are found
36
+ }
37
+ }
38
+
39
+ publishing {
40
+ repositories {
41
+ maven {
42
+ name = " GitHubPackages"
43
+ url = uri(" https://maven.pkg.github.com/ctrl-hub/sdk.kotlin" )
44
+
45
+ credentials {
46
+ username = System .getenv(" GITHUB_USERNAME" )
47
+ password = System .getenv(" GITHUB_TOKEN" )
48
+ }
49
+ }
50
+ }
51
+
52
+ publications {
53
+ create<MavenPublication >(" gpr" ) {
54
+ groupId = " com.ctrlhub"
55
+ artifactId = " sdk"
56
+ version = project.getGitTag()
57
+
58
+ from(components[" kotlin" ])
59
+ }
60
+ }
61
+ }
62
+
26
63
tasks.test {
27
64
useJUnitPlatform()
28
65
}
You can’t perform that action at this time.
0 commit comments