mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-06 08:40:19 +00:00
add nmcp
This commit is contained in:
15
build.gradle
15
build.gradle
@@ -19,6 +19,21 @@ buildscript {
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.versions)
|
alias(libs.plugins.versions)
|
||||||
|
alias(libs.plugins.nmcp.aggregation)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
||||||
|
nmcpAggregation {
|
||||||
|
centralPortal {
|
||||||
|
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||||
|
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||||
|
verificationTimeout = Duration.ofSeconds(0)
|
||||||
|
publishingType = "USER_MANAGED"
|
||||||
|
}
|
||||||
|
|
||||||
|
publishAllProjectsProbablyBreakingProjectIsolation()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
@@ -29,6 +29,7 @@ ksp = "2.1.20-1.0.31"
|
|||||||
kotlin-poet = "1.18.1"
|
kotlin-poet = "1.18.1"
|
||||||
|
|
||||||
versions = "0.51.0"
|
versions = "0.51.0"
|
||||||
|
nmcp = "0.1.5"
|
||||||
|
|
||||||
android-gradle = "8.9.+"
|
android-gradle = "8.9.+"
|
||||||
dexcount = "4.0.0"
|
dexcount = "4.0.0"
|
||||||
@@ -123,3 +124,4 @@ jb-compose = { id = "org.jetbrains.compose", version.ref = "jb-compose" }
|
|||||||
kt-jb-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kt" }
|
kt-jb-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kt" }
|
||||||
|
|
||||||
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }
|
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }
|
||||||
|
nmcp-aggregation = { id = "com.gradleup.nmcp.aggregation", version.ref = "nmcp" }
|
||||||
|
@@ -1 +1 @@
|
|||||||
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/MicroUtils/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"It is set of projects with micro tools for avoiding of routines coding","url":"https://github.com/InsanusMokrassar/MicroUtils/","vcsUrl":"https://github.com/InsanusMokrassar/MicroUtils.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"000Sanya","name":"Syrov Aleksandr","eMail":"000sanya.000sanya@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/MicroUtils"},{"name":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"},"includeCentralSonatypeUploadingScript":true}}
|
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/MicroUtils/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"It is set of projects with micro tools for avoiding of routines coding","url":"https://github.com/InsanusMokrassar/MicroUtils/","vcsUrl":"https://github.com/InsanusMokrassar/MicroUtils.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"000Sanya","name":"Syrov Aleksandr","eMail":"000sanya.000sanya@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/MicroUtils"},{"name":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"},"includeCentralSonatypeUploadingScript":false}}
|
@@ -1 +1 @@
|
|||||||
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/MicroUtils/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"It is set of projects with micro tools for avoiding of routines coding","url":"https://github.com/InsanusMokrassar/MicroUtils/","vcsUrl":"https://github.com/InsanusMokrassar/MicroUtils.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"000Sanya","name":"Syrov Aleksandr","eMail":"000sanya.000sanya@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/MicroUtils"},{"name":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"},"includeCentralSonatypeUploadingScript":true},"type":"JVM"}
|
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/MicroUtils/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"It is set of projects with micro tools for avoiding of routines coding","url":"https://github.com/InsanusMokrassar/MicroUtils/","vcsUrl":"https://github.com/InsanusMokrassar/MicroUtils.git","developers":[{"id":"InsanusMokrassar","name":"Aleksei Ovsiannikov","eMail":"ovsyannikov.alexey95@gmail.com"},{"id":"000Sanya","name":"Syrov Aleksandr","eMail":"000sanya.000sanya@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/MicroUtils"},{"name":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"},"includeCentralSonatypeUploadingScript":false},"type":"JVM"}
|
@@ -1,28 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
function send_notification() {
|
|
||||||
echo "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
function assert_success() {
|
|
||||||
"${@}"
|
|
||||||
local status=${?}
|
|
||||||
if [ ${status} -ne 0 ]; then
|
|
||||||
send_notification "### Error ${status} at: ${BASH_LINENO[*]} ###"
|
|
||||||
exit ${status}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_success ./uploadSonatypePublication.main.kts --drop
|
|
||||||
|
|
||||||
readarray -t projects <<< "`./gradlew getPublishableModules --quiet`"
|
|
||||||
for project in "${projects[@]}"; do
|
|
||||||
echo "Start publishing of $project"
|
|
||||||
assert_success ./gradlew "$project:publishAllPublicationsToSonatypeRepository" --no-parallel --quiet
|
|
||||||
echo "Complete publishing of $project"
|
|
||||||
echo "Start uploading of $project"
|
|
||||||
assert_success ./uploadSonatypePublication.main.kts --user_manager
|
|
||||||
echo "Complete uploading of $project"
|
|
||||||
done
|
|
||||||
|
|
||||||
assert_success ./uploadSonatypePublication.main.kts --automatic
|
|
@@ -1,139 +0,0 @@
|
|||||||
#!/usr/bin/env kotlin
|
|
||||||
|
|
||||||
@file:Repository("https://repo.maven.apache.org/maven2/")
|
|
||||||
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
|
|
||||||
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import kotlinx.serialization.json.JsonArray
|
|
||||||
import kotlinx.serialization.json.JsonObject
|
|
||||||
import kotlinx.serialization.json.JsonPrimitive
|
|
||||||
import java.net.http.HttpRequest.BodyPublisher
|
|
||||||
import java.net.http.HttpClient
|
|
||||||
import java.net.http.HttpRequest
|
|
||||||
import java.net.http.HttpResponse
|
|
||||||
import java.net.URI
|
|
||||||
|
|
||||||
class CentralSonatypeOSSRHApi(
|
|
||||||
private val bearer: String,
|
|
||||||
) {
|
|
||||||
data class SonatypeOSSRHRepository(
|
|
||||||
val key: String,
|
|
||||||
val portalDeploymentId: String?,
|
|
||||||
val state: String,
|
|
||||||
)
|
|
||||||
|
|
||||||
private val baseUrl = "https://ossrh-staging-api.central.sonatype.com/manual"
|
|
||||||
private val client = HttpClient.newHttpClient()
|
|
||||||
private fun makeRequest(
|
|
||||||
method: String,
|
|
||||||
suffix: String,
|
|
||||||
bodyPublisher: BodyPublisher = HttpRequest.BodyPublishers.ofString("")
|
|
||||||
): JsonObject? {
|
|
||||||
val request = HttpRequest.newBuilder()
|
|
||||||
.uri(URI.create("$baseUrl/$suffix"))
|
|
||||||
.method(method, bodyPublisher)
|
|
||||||
.header("Content-Type", "application/json")
|
|
||||||
.header("Authorization", "Bearer $bearer")
|
|
||||||
.build()
|
|
||||||
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
|
|
||||||
println(response)
|
|
||||||
val responseBody = response.body()
|
|
||||||
println(responseBody)
|
|
||||||
return when {
|
|
||||||
response.statusCode() == 200 && responseBody.isNotEmpty() -> {
|
|
||||||
return Json.decodeFromString(JsonObject.serializer(), responseBody)
|
|
||||||
}
|
|
||||||
response.statusCode() == 200 -> {
|
|
||||||
return JsonObject(emptyMap())
|
|
||||||
}
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun repositories(
|
|
||||||
profileId: String? = null,
|
|
||||||
state: String? = null,
|
|
||||||
ip: String? = null,
|
|
||||||
): List<SonatypeOSSRHRepository>? {
|
|
||||||
val repositories = makeRequest(
|
|
||||||
"GET",
|
|
||||||
"search/repositories?${state ?.let { "state=$it" } ?: ""}${profileId ?.let { "&profile_id=$it" } ?: ""}${ip ?.let { "&ip=$it" } ?: ""}"
|
|
||||||
) ?.get("repositories") as? JsonArray
|
|
||||||
|
|
||||||
return repositories ?.mapNotNull {
|
|
||||||
val asObject = it as? JsonObject ?:return@mapNotNull null
|
|
||||||
SonatypeOSSRHRepository(
|
|
||||||
(asObject["key"] as JsonPrimitive).content,
|
|
||||||
(asObject["portal_deployment_id"] as? JsonPrimitive) ?.content,
|
|
||||||
(asObject["state"] as JsonPrimitive).content,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun drop(repositoryKey: String, ): Boolean {
|
|
||||||
val dropped = makeRequest(
|
|
||||||
"DELETE",
|
|
||||||
"drop/repository/$repositoryKey"
|
|
||||||
)
|
|
||||||
|
|
||||||
return dropped != null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun uploadDefault(requestedNamespace: String, publishingType: String? = null): Boolean {
|
|
||||||
val uploaded = makeRequest(
|
|
||||||
"POST",
|
|
||||||
"upload/defaultRepository/$requestedNamespace?${publishingType ?.let { "publishing_type=$publishingType" } ?: ""}"
|
|
||||||
)
|
|
||||||
|
|
||||||
return uploaded != null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun upload(repositoryKey: String, publishingType: String? = null): Boolean {
|
|
||||||
val uploaded = makeRequest(
|
|
||||||
"POST",
|
|
||||||
"upload/repository/$repositoryKey?${publishingType ?.let { "publishing_type=$publishingType" } ?: ""}"
|
|
||||||
)
|
|
||||||
|
|
||||||
return uploaded != null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val repos_state = runCatching { System.getenv("repos_state").takeIf { it.isNotEmpty() } }.getOrNull() ?: "open"
|
|
||||||
val publishing_type = runCatching { System.getenv("publishing_type").takeIf { it.isNotEmpty() } }.getOrNull() ?: "user_managed"
|
|
||||||
val api = CentralSonatypeOSSRHApi(
|
|
||||||
let {
|
|
||||||
val username = System.getenv("SONATYPE_USER")
|
|
||||||
val password = System.getenv("SONATYPE_PASSWORD")
|
|
||||||
java.util.Base64.getEncoder().encodeToString("$username:$password".encodeToByteArray())
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if (args.contains("--drop")) {
|
|
||||||
api.repositories()?.forEach {
|
|
||||||
println("Start dropping of ${it.key}")
|
|
||||||
val uploaded = api.drop(it.key)
|
|
||||||
|
|
||||||
println("Complete dropping of ${it.key}. Status ok: $uploaded")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.contains("--user_manager")) {
|
|
||||||
api.repositories()?.forEach {
|
|
||||||
if (it.state == "open") {
|
|
||||||
println("Start uploading of ${it.key}")
|
|
||||||
val uploaded = api.upload(it.key, "user_managed")
|
|
||||||
|
|
||||||
println("Complete uploading of ${it.key}. Status ok: $uploaded")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.contains("--automatic")) {
|
|
||||||
api.repositories()?.forEach {
|
|
||||||
if (it.state == "closed") {
|
|
||||||
println("Start uploading of ${it.key} with auto mode ")
|
|
||||||
val uploaded = api.upload(it.key, "automatic")
|
|
||||||
|
|
||||||
println("Complete uploading of ${it.key} with auto mode . Status ok: $uploaded")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user