Skip to content

Commit

Permalink
update release plugin for mavencentral
Browse files Browse the repository at this point in the history
  • Loading branch information
froks committed Jun 15, 2024
1 parent 9d0632c commit 051b80a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish_on_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_STAGING_USERNAME: ${{ secrets.OSSRH_STAGING_USERNAME }}
- name: release
uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
with:
Expand All @@ -41,3 +42,4 @@ jobs:
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_STAGING_USERNAME: ${{ secrets.OSSRH_STAGING_USERNAME }}
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
apply<NexusReleasePlugin>()

group = "io.github.doip-sim-ecu"
version = "0.12.1"
version = "0.12.2"

repositories {
gradlePluginPortal()
Expand Down Expand Up @@ -145,4 +145,5 @@ signing {
configure<NexusReleaseExtension> {
username.set(System.getenv("OSSRH_USERNAME"))
password.set(System.getenv("OSSRH_PASSWORD"))
stagingUserName.set(System.getenv("OSSRH_STAGING_USERNAME"))
}
9 changes: 4 additions & 5 deletions buildSrc/src/main/kotlin/NexusClient.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.*
import org.gradle.api.logging.Logger
Expand Down Expand Up @@ -76,7 +75,7 @@ class NexusClient(private val logger: Logger, private val config: NexusReleaseEx
val repositories = get<ProfileRepository>("/service/local/staging/profile_repositories")
return repositories.data
.filter {
(config.stagingId.orNull == null && config.username.get() == it.userId) ||
(config.stagingId.orNull == null && config.stagingUserName.get() == it.userId) ||
it.repositoryId == config.stagingId.orNull
}
}
Expand Down Expand Up @@ -119,7 +118,7 @@ class NexusClient(private val logger: Logger, private val config: NexusReleaseEx
val connection = createUrl(path).openConnection() as HttpURLConnection
connection.connectTimeout = config.connectTimeout.get().toMillis().toInt()
connection.requestMethod = method
connection.setRequestProperty("Authorization", basicAuth)
connection.setRequestProperty("Authorization", bearerAuth)
connection.setRequestProperty("Accept", "application/json")
if (method != "GET") {
connection.setRequestProperty("Content-Type", "application/json")
Expand All @@ -142,9 +141,9 @@ class NexusClient(private val logger: Logger, private val config: NexusReleaseEx
URL(this.scheme, this.authority, path)
}

private val basicAuth: String
private val bearerAuth: String
get() =
"Basic " + "${config.username.get()}:${config.password.get()}".encodeToByteArray().encodeBase64()
"Bearer " + "${config.username.get()}:${config.password.get()}".encodeToByteArray().encodeBase64()
}

class HttpException(
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/NexusReleasePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ open class NexusReleaseExtension(project: Project) {
}

val stagingId: Property<String> = project.objects.property(String::class.java)
val stagingUserName: Property<String> = project.objects.property(String::class.java)
val username: Property<String> = project.objects.property(String::class.java)
val password: Property<String> = project.objects.property(String::class.java)

Expand Down

0 comments on commit 051b80a

Please sign in to comment.