Unverified Commit 30b588f5 authored by Alexey Tsvetkov's avatar Alexey Tsvetkov Committed by GitHub

Fix downloading artifacts for GH release (#389)

parent a97f6e93
......@@ -19,15 +19,6 @@ fun targetSuffix(os: OS, arch: Arch): String {
return "${os.id}_${arch.id}"
}
buildscript {
dependencies {
classpath("org.kohsuke:github-api:1.116")
}
repositories {
mavenCentral()
}
}
val skiko = SkikoProperties(rootProject)
val buildType = skiko.buildType
val generatedKotlin = "$buildDir/kotlin/commonMain"
......
......@@ -2,15 +2,8 @@ import org.kohsuke.github.*
import org.jetbrains.compose.internal.publishing.*
val skiko = SkikoProperties(project)
val mavenCentral = MavenCentralProperties(project)
val GITHUB_REPO = "JetBrains/skiko"
fun connectToGitHub() =
GitHubBuilder()
.withOAuthToken(System.getenv("SKIKO_GH_RELEASE_TOKEN"))
.build()
repositories {
maven(skiko.composeRepoUrl)
}
val skikoArtifactIds: List<String> =
listOf(
......@@ -29,30 +22,40 @@ val skikoArtifactIds: List<String> =
SkikoArtifacts.nativeArtifactIdFor(OS.IOS, Arch.Arm64),
)
val githubArtifacts by configurations.creating
dependencies {
for (artifactId in skikoArtifactIds) {
githubArtifacts("org.jetbrains.skiko:$artifactId:${skiko.deployVersion}") {
isTransitive = false
}
}
val downloadSkikoArtifactsFromComposeDev by tasks.registering(DownloadFromSpaceMavenRepoTask::class) {
modulesToDownload.set(skikoMavenModules(skiko.deployVersion))
spaceRepoUrl.set("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
val createGithubRelease by tasks.registering {
dependsOn(downloadSkikoArtifactsFromComposeDev)
doLast {
check(skiko.isRelease) { "This task should only be called for releases!" }
val gh = connectToGitHub()
val githubVersion = skiko.releaseGithubVersion
val githubCommit = skiko.releaseGithubCommit
val repo = gh.getRepository("JetBrains/skiko")
val repo = gh.getRepository(GITHUB_REPO)
val release = repo.createRelease("v$githubVersion")
.name("Version $githubVersion")
.commitish(githubCommit)
.create()
githubArtifacts
.filter { it.extension == "jar" }
.forEach { release.uploadAsset(it, "application/zip") }
val artifactsToUpload = skikoMavenModules(skiko.deployVersion).get().map { module ->
val baseName = "${module.artifactId}-${module.version}"
val pom = module.localDir.resolve("$baseName.pom")
val regex = "<packaging>([a-zA-Z0-9]+)</packaging>".toRegex()
val ext = regex.find(pom.readText())?.groupValues?.getOrNull(1) ?: "jar"
module.localDir.resolve("$baseName.$ext").also {
check(it.exists()) {
"'$it' does not exist"
}
}
}
for (artifact in artifactsToUpload) {
logger.info("Uploading '$artifact'")
release.uploadAsset(artifact, "application/zip")
}
}
}
......@@ -64,8 +67,21 @@ val deleteGithubRelease by tasks.registering {
}
}
fun skikoMavenModules(version: Provider<String>): Provider<List<ModuleToUpload>> =
version.map { version ->
val uploadSkikoArtifactsToMavenCentral by tasks.registering(UploadToSonatypeTask::class) {
dependsOn(downloadSkikoArtifactsFromComposeDev)
version.set(skiko.deployVersion)
modulesToUpload.set(skikoMavenModules(skiko.deployVersion))
sonatypeServer.set("https://oss.sonatype.org")
user.set(mavenCentral.user)
password.set(mavenCentral.password)
autoCommitOnSuccess.set(mavenCentral.autoCommitOnSuccess)
stagingProfileName.set("org.jetbrains.skiko")
}
fun Project.skikoMavenModules(version: String): Provider<List<ModuleToUpload>> =
provider {
val artifactsDir = buildDir.resolve("skiko-artifacts")
skikoArtifactIds.map { artifactId ->
......@@ -79,21 +95,7 @@ fun skikoMavenModules(version: Provider<String>): Provider<List<ModuleToUpload>>
}
}
val mavenCentral = MavenCentralProperties(project)
val downloadSkikoArtifactsFromComposeDev by tasks.registering(DownloadFromSpaceMavenRepoTask::class) {
modulesToDownload.set(skikoMavenModules(mavenCentral.version))
spaceRepoUrl.set("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
val uploadSkikoArtifactsToMavenCentral by tasks.registering(UploadToSonatypeTask::class) {
dependsOn(downloadSkikoArtifactsFromComposeDev)
version.set(mavenCentral.version)
modulesToUpload.set(skikoMavenModules(mavenCentral.version))
sonatypeServer.set("https://oss.sonatype.org")
user.set(mavenCentral.user)
password.set(mavenCentral.password)
autoCommitOnSuccess.set(mavenCentral.autoCommitOnSuccess)
stagingProfileName.set("org.jetbrains.skiko")
}
fun connectToGitHub() =
GitHubBuilder()
.withOAuthToken(System.getenv("SKIKO_GH_RELEASE_TOKEN"))
.build()
\ No newline at end of file
......@@ -10,6 +10,7 @@ pluginManagement {
}
dependencies {
classpath("org.jetbrains.compose.internal.build-helpers:publishing:0.1.0")
classpath("org.kohsuke:github-api:1.116")
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment