Skip to content

Commit

Permalink
Improve KorGE publishing (#2247)
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Jun 20, 2024
1 parent 3eeac1b commit ef84f6a
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 170 deletions.
71 changes: 16 additions & 55 deletions .github/workflows/DEPLOY.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,63 +21,24 @@ env:
JAVA_DISTRIBUTION: zulu

jobs:
create-staging-repo:
runs-on: ubuntu-latest
outputs:
stagedRepositoryId: ${{ steps.createStagedRepositoryId.outputs.stagedRepositoryId }}
env:
DISABLE_JAVASCRIPT_TEST: true
DISABLE_KOTLIN_NATIVE: true
DISABLE_ANDROID: true
DISABLE_SANDBOX: true
steps:
- run: "echo FORCED_VERSION=$FORCED_VERSION"
- uses: actions/checkout@v3
- { name: Use Node.js 20.x, uses: actions/setup-node@v3, with: { node-version: 20.x } }
- { name: Set up JDK, uses: actions/setup-java@v3, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } }
- { name: Replace gradle wrapper, run: "sed 's/-all/-bin/g' gradle/wrapper/gradle-wrapper.properties > gradle/wrapper/gradle-wrapper.properties.bak; cp gradle/wrapper/gradle-wrapper.properties.bak gradle/wrapper/gradle-wrapper.properties" }
- { name: Prepare Gradle, uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc } # v2.8.0
- run: sudo apt-get install xvfb
- id: createStagedRepositoryId
run: xvfb-run --auto-servernum ./gradlew --no-daemon --info --stacktrace startReleasingMavenCentral

publish:
strategy:
fail-fast: false # Once working, comment this
matrix:
include:
- { os: macos-11, tasks: publishIosArm64PublicationToMavenRepository publishIosX64PublicationToMavenRepository publishIosSimulatorArm64PublicationToMavenRepository }
- { os: macos-11, tasks: publishTvosX64PublicationToMavenRepository publishTvosArm64PublicationToMavenRepository publishTvosSimulatorArm64PublicationToMavenRepository }
- { os: ubuntu-latest, tasks: publishKotlinMultiplatformPublicationToMavenRepository publishJvmPublicationToMavenRepository }
- { os: ubuntu-latest, tasks: publishWasmJsPublicationToMavenRepository publishJsPublicationToMavenRepository publishAndroidPublicationToMavenRepository }
runs-on: ${{ matrix.os }}
needs: [create-staging-repo]
env:
stagedRepositoryId: ${{needs.create-staging-repo.outputs.stagedRepositoryId}}
steps:
- uses: actions/checkout@v3
- { name: Use Node.js 20.x, uses: actions/setup-node@v3, with: { node-version: 20.x } }
- { name: Set up JDK, uses: actions/setup-java@v3, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } }
- { name: Replace gradle wrapper, run: "sed 's/-all/-bin/g' gradle/wrapper/gradle-wrapper.properties > gradle/wrapper/gradle-wrapper.properties.bak; cp gradle/wrapper/gradle-wrapper.properties.bak gradle/wrapper/gradle-wrapper.properties" }
- { name: Prepare Gradle, uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc } # v2.8.0
#- run: sudo apt-get install xvfb
#- run: xvfb-run --auto-servernum ./gradlew --no-daemon checkReleasingMavenCentral
- run: ./gradlew checkReleasingMavenCentral
- run: ./gradlew ${{ matrix.tasks }}

publish-finalize:
runs-on: ubuntu-latest
needs: [publish]
env:
stagedRepositoryId: ${{needs.create-staging-repo.outputs.stagedRepositoryId}}
DISABLE_JAVASCRIPT_TEST: true
DISABLE_KOTLIN_NATIVE: true
DISABLE_ANDROID: true
DISABLE_SANDBOX: true
runs-on: macos-11
steps:
- uses: actions/checkout@v3
- { name: Checkout, uses: actions/checkout@v3 }
- { name: Use Node.js 20.x, uses: actions/setup-node@v3, with: { node-version: 20.x } }
- { name: Set up JDK, uses: actions/setup-java@v3, with: { distribution: "${{ env.JAVA_DISTRIBUTION }}", java-version: "${{ env.JAVA_VERSION }}" } }
- { name: Replace gradle wrapper, run: "sed 's/-all/-bin/g' gradle/wrapper/gradle-wrapper.properties > gradle/wrapper/gradle-wrapper.properties.bak; cp gradle/wrapper/gradle-wrapper.properties.bak gradle/wrapper/gradle-wrapper.properties" }
- { name: Replace Gradle Wrapper, run: "sed 's/-all/-bin/g' gradle/wrapper/gradle-wrapper.properties > gradle/wrapper/gradle-wrapper.properties.bak; cp gradle/wrapper/gradle-wrapper.properties.bak gradle/wrapper/gradle-wrapper.properties" }
- { name: Prepare Gradle, uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc } # v2.8.0
- run: ./gradlew releaseMavenCentral
- { name: Initialize Gradle, run: ./gradlew }
# To ensure we are fine before staging repository
- { name: Publish Publications To Maven Local, run: ./gradlew publishToMavenLocal }
- { name: Generate artifacts .tar.zstd, run: ./gradlew generateArtifactsTarZstd }
- name: Github Release
uses: softprops/action-gh-release@69320dbe05506a9a39fc8ae11030b214ec2d1f87
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
build/korge-*.tar.zstd
- { name: Start Maven Central Staging Repository, run: ./gradlew startReleasingMavenCentral }
- { name: Publish Publications To Maven Repository, run: "./gradlew publishAllPublicationsToMavenRepository" }
- { name: Release to Maven Central, run: ./gradlew releaseMavenCentral }
57 changes: 0 additions & 57 deletions .github/workflows/DEPLOY_ONLY_GRADLE_PLUGIN.yml

This file was deleted.

58 changes: 0 additions & 58 deletions .github/workflows/FAKE_TESTDEPLOY.yml

This file was deleted.

71 changes: 71 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import korlibs.root.*

plugins {
//id "com.dorongold.task-tree" version "2.1.1"
// ./gradlew :kds:compileKotlinJs taskTree
Expand All @@ -20,3 +22,72 @@ tasks {
}
}
}

afterEvaluate {
allprojects {
val publishing = extensions.findByType(PublishingExtension::class.java)
if (publishing == null) {
val copyArtifactsToDirectory by tasks.registering(Task::class) {
}
} else {
val copyArtifactsToDirectory by tasks.registering(Task::class) {
dependsOn("publishToMavenLocal")

doLast {
val base = rootProject.layout.buildDirectory.dir("artifacts")
for (pub in publishing.publications.filterIsInstance<MavenPublication>()) {
//println(pub.artifacts.toList())
val basePath = pub.groupId.replace(".", "/") + "/" + pub.artifactId + "/" + pub.version
val baseDir = File(base.get().asFile, basePath)

val m2Dir = File(File(System.getProperty("user.home"), ".m2/repository"), basePath)

//println("m2Dir=$m2Dir")
// .module
copy {
from(m2Dir)
into(baseDir)
}
}
}
}
}
}
}

val mversion = project.getForcedVersion()

tasks {
val generateArtifactsZip by registering(Zip::class) {
subprojects {
dependsOn("${this.path}:copyArtifactsToDirectory")
}
from(rootProject.layout.buildDirectory.dir("artifacts"))
archiveFileName = "korge-$mversion.zip"
destinationDirectory = rootProject.layout.buildDirectory
}

val generateArtifactsTar by registering(Tar::class) {
subprojects {
dependsOn("${this.path}:copyArtifactsToDirectory")
}
from(rootProject.layout.buildDirectory.dir("artifacts"))
//compression = Compression.GZIP
//into(rootProject.layout.buildDirectory)
archiveFileName = "korge-$mversion.tar"
destinationDirectory = rootProject.layout.buildDirectory
}

// winget install zstd
val generateArtifactsTarZstd by registering(Exec::class) {
val rootFile = rootProject.layout.buildDirectory.asFile.get()
dependsOn(generateArtifactsTar)
commandLine(
"zstd", "-z",
//"--ultra", "-22",
"-17",
"-f", File(rootFile, "korge-$mversion.tar").absolutePath,
"-o", File(rootFile, "korge-$mversion.tar.zstd").absolutePath
)
}
}

0 comments on commit ef84f6a

Please sign in to comment.