Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong dto structure (due to broken OpenAPI schema file) #108

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions gradle/build-logic/src/main/kotlin/PublishToMavenCentral.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.logging.*
import io.ktor.client.request.*
import io.ktor.client.request.forms.*
import io.ktor.http.*
import io.ktor.http.ContentType.*
import io.ktor.serialization.kotlinx.json.*
import io.ktor.util.*
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.io.asSource
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.repositories.PasswordCredentials
import org.gradle.api.file.ConfigurableFileCollection
Expand Down Expand Up @@ -90,9 +91,11 @@ abstract class PublishWorker : WorkAction<PublishWorker.PublishParameters> {
}
}
}
val deploymentId = client.submitFormWithBinaryData(
url = "api/v1/publisher/upload",
formData = formData {
val deploymentId = client.post(
urlString = "api/v1/publisher/upload",
) {
contentType(MultiPart.FormData)
setBody(MultiPartFormDataContent(formData {
append(
key = "bundle",
filename = zipFile.name,
Expand All @@ -101,47 +104,37 @@ abstract class PublishWorker : WorkAction<PublishWorker.PublishParameters> {
) {
transferFrom(zipFile.inputStream().asSource())
}
},
) {
parameter("publishingType", "AUTOMATIC")
}))
parameter("publishingType", PublishingTypePublishingType.Automatic)
}.body<String>()
while (true) {
delay(500.milliseconds)
val status = client.post("api/v1/publisher/status") {
parameter("id", deploymentId)
}.body<Status>()
when (status.deployment.value.deploymentState) {
}.body<CheckStatus>()
when (status.deploymentState) {
DeploymentState.PENDING,
DeploymentState.VALIDATING,
DeploymentState.VALIDATED,
-> continue

DeploymentState.PUBLISHING,
DeploymentState.PUBLISHED,
-> break
DeploymentState.FAILED -> error(status.deployment.value.error)

DeploymentState.FAILED -> error(status.errors)
}
}
}
}

@Serializable
private data class Status(
val deployment: Deployment,
)

@Serializable
private data class Deployment(
val summary: String,
val value: Value,
)

@Serializable
private data class Value(
private data class CheckStatus(
val deploymentId: String,
val deploymentName: String,
val deploymentState: DeploymentState,
val purls: List<String>,
val error: JsonObject,
val errors: List<String>,
)

@Serializable
Expand All @@ -154,3 +147,12 @@ private enum class DeploymentState {
FAILED,
;
}

@Serializable
public enum class PublishingTypePublishingType {
@SerialName(value = "USER_MANAGED")
UserManaged,

@SerialName(value = "AUTOMATIC")
Automatic,
}
Loading