From 02c93415a8bef69452376c3058917a25bbd88954 Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 28 Dec 2023 03:05:31 +0100 Subject: [PATCH 1/6] Update publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 86375cf..68d33ea 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -41,4 +41,4 @@ jobs: arguments: publish env: USERNAME: ${{ github.actor }} - TOKEN: ${{ secrets.GITHUB_TOKEN }} + TOKEN: ${{ secrets.GIT_TOKEN }} From 371a781fb852120be008781e6a9caababaaeb759 Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 28 Dec 2023 03:06:50 +0100 Subject: [PATCH 2/6] Update publish.yml --- .github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 68d33ea..68e95b5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,9 +8,9 @@ name: Gradle Package on: - release: - types: - - created + push: + tags: + - v* jobs: build: From 6047432256532547f7a3d1b3acc123ac34fe4b57 Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 28 Dec 2023 03:15:51 +0100 Subject: [PATCH 3/6] fix: Multiple repos Signed-off-by: Avior --- build.gradle.kts | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2bff5b7..7f6e21e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,36 +62,6 @@ publishing { from(components["java"]) - pom { - name.set("TCGdex SDK") - description.set("Communicate with the Open Source TCGdex API in Kotlin/Java using the SDK") - url.set("https://github.com/tcgdex/java-sdk") - licenses { - license { - name.set("MIT License") - url.set("https://github.com/tcgdex/java-sdk/blob/master/LICENSE.txt") - } - } - developers { - developer { - id.set("avior") - name.set("Avior") - email.set("contact@tcgdex.net") - } - } - scm { - connection.set("scm:git@github.com:tcgdex/java-sdk.git") - url.set("https://github.com/tcgdex/java-sdk") - } - } - } - register("gpr") { - // groupId = group - artifactId = artifact - // version = ver - - from(components["java"]) - pom { name.set("TCGdex SDK") description.set("Communicate with the Open Source TCGdex API in Kotlin/Java using the SDK") From e1d55b071a005726073ffc18920e0530b65ea223 Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 28 Dec 2023 03:20:39 +0100 Subject: [PATCH 4/6] fix: Build not using tag Signed-off-by: Avior --- build.gradle.kts | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7f6e21e..ac81d1e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,9 +8,32 @@ plugins { `maven-publish` } +// from: https://discuss.kotlinlang.org/t/use-git-hash-as-version-number-in-build-gradle-kts/19818/8 +fun String.runCommand( + workingDir: File = File("."), + timeoutAmount: Long = 60, + timeoutUnit: TimeUnit = TimeUnit.SECONDS +): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex())) + .directory(workingDir) + .redirectOutput(ProcessBuilder.Redirect.PIPE) + .redirectError(ProcessBuilder.Redirect.PIPE) + .start() + .apply { waitFor(timeoutAmount, timeoutUnit) } + .run { + val error = errorStream.bufferedReader().readText().trim() + if (error.isNotEmpty()) { + return@run "" + } + inputStream.bufferedReader().readText().trim() + } + +val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir) +val tag = "git tag -l --points-at HEAD".runCommand(workingDir = rootDir) +val commitId = "git rev-parse HEAD".runCommand(workingDir = rootDir) + val artifact = System.getenv("artifact") ?: "sdk" group = System.getenv("group") ?: "net.tcgdex" -version = System.getenv("version") ?: "2.0.0" +version = System.getenv("version") ?: tag.drop(1) ?: "2.0.0" repositories { mavenCentral() @@ -56,9 +79,9 @@ val javadocJar = tasks.named("javadocJar") { publishing { publications { create("maven") { - // groupId = group + groupId = group artifactId = artifact - // version = ver + version = ver from(components["java"]) From 666e87697060f08b7b9d6194d6f930b1bc121e9d Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 28 Dec 2023 03:23:39 +0100 Subject: [PATCH 5/6] fix: typing Signed-off-by: Avior --- build.gradle.kts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ac81d1e..3e1383e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,9 +31,12 @@ val branch = "git rev-parse --abbrev-ref HEAD".runCommand(workingDir = rootDir) val tag = "git tag -l --points-at HEAD".runCommand(workingDir = rootDir) val commitId = "git rev-parse HEAD".runCommand(workingDir = rootDir) -val artifact = System.getenv("artifact") ?: "sdk" -group = System.getenv("group") ?: "net.tcgdex" -version = System.getenv("version") ?: tag.drop(1) ?: "2.0.0" +val finalVersion = System.getenv("version") as String? ?: tag.drop(1) ?: "2.0.0" +val finalGroup = System.getenv("group") as String? ?: "net.tcgdex" +val artifact = System.getenv("artifact") as String? ?: "sdk" + +group = finalGroup +version = finalVersion repositories { mavenCentral() @@ -79,9 +82,9 @@ val javadocJar = tasks.named("javadocJar") { publishing { publications { create("maven") { - groupId = group + groupId = finalGroup artifactId = artifact - version = ver + version = finalVersion from(components["java"]) From c9c297f76797fe53ec632127b520f83d26d055d8 Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 28 Dec 2023 03:29:44 +0100 Subject: [PATCH 6/6] Update publish.yml --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 68e95b5..a7bbcfc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -41,4 +41,4 @@ jobs: arguments: publish env: USERNAME: ${{ github.actor }} - TOKEN: ${{ secrets.GIT_TOKEN }} + TOKEN: ${{ secrets.REPO_TOKEN }}