mirror of
https://github.com/tcgdex/java-sdk.git
synced 2025-04-22 10:52:14 +00:00
feat: Auto publish to Github Packages on tag (#31)
All checks were successful
All checks were successful
This commit is contained in:
parent
7c7ca1742b
commit
13e719d1fb
8
.github/workflows/publish.yml
vendored
8
.github/workflows/publish.yml
vendored
@ -8,9 +8,9 @@
|
|||||||
name: Gradle Package
|
name: Gradle Package
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
push:
|
||||||
types:
|
tags:
|
||||||
- created
|
- v*
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -41,4 +41,4 @@ jobs:
|
|||||||
arguments: publish
|
arguments: publish
|
||||||
env:
|
env:
|
||||||
USERNAME: ${{ github.actor }}
|
USERNAME: ${{ github.actor }}
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.REPO_TOKEN }}
|
||||||
|
@ -8,9 +8,35 @@ plugins {
|
|||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
val artifact = System.getenv("artifact") ?: "sdk"
|
// from: https://discuss.kotlinlang.org/t/use-git-hash-as-version-number-in-build-gradle-kts/19818/8
|
||||||
group = System.getenv("group") ?: "net.tcgdex"
|
fun String.runCommand(
|
||||||
version = System.getenv("version") ?: "2.0.0"
|
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 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 {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -56,39 +82,9 @@ val javadocJar = tasks.named<Jar>("javadocJar") {
|
|||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>("maven") {
|
create<MavenPublication>("maven") {
|
||||||
// groupId = group
|
groupId = finalGroup
|
||||||
artifactId = artifact
|
artifactId = artifact
|
||||||
// version = ver
|
version = finalVersion
|
||||||
|
|
||||||
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<MavenPublication>("gpr") {
|
|
||||||
// groupId = group
|
|
||||||
artifactId = artifact
|
|
||||||
// version = ver
|
|
||||||
|
|
||||||
from(components["java"])
|
from(components["java"])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user