Skip to content

Commit

Permalink
Test publishing on a single machine
Browse files Browse the repository at this point in the history
  • Loading branch information
StefMa committed Sep 15, 2023
1 parent 6dc7dbf commit e8dbef7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 58 deletions.
45 changes: 7 additions & 38 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,16 @@ on:
pull_request: # TODO: Fix me, use git tag push ...

jobs:
publish-kmp-metadata:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Publish metadata
run: ./gradlew publishKotlinMultiplatformPublicationToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}

publish-jvm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Publish jvm
run: ./gradlew publishJvmPublicationToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}

publish-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Publish linux
run: ./gradlew publishNativePublicationToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}

publish-darwin:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Publish darwin
run: ./gradlew publishNativePublicationToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}

publish-mingw:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Publish mingw
run: ./gradlew.bat publishNativePublicationToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew publishKotlinMultiplatformPublicationToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}
./gradlew publishNative1ToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}
./gradlew publishNative2ToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}
./gradlew publishNative3ToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}
./gradlew publishNative4ToGitHubPackagesRepository -PgithubPackagesUser=$GITHUB_ACTOR -PgithubPackagesKey=${{ secrets.GITHUB_TOKEN }}
45 changes: 25 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ kotlin {
}
}

when {
hostOs == "Mac OS X" && isArm64 -> macosArm64("native")
hostOs == "Mac OS X" && !isArm64 -> macosX64("native")
hostOs == "Linux" && !isArm64 -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
macosArm64("native1")
macosX64("native2")
linuxX64("native3")
mingwX64("native4")

sourceSets {
val ktorVersion = "2.3.4"
Expand All @@ -53,18 +50,26 @@ kotlin {
}
}
val jvmTest by getting
val nativeMain by getting {
val native1Main by getting {
dependencies {
when {
hostOs == "Mac OS X" -> implementation("io.ktor:ktor-client-darwin:$ktorVersion")
hostOs == "Linux" -> implementation("io.ktor:ktor-client-curl:$ktorVersion")
isMingwX64 -> implementation("io.ktor:ktor-client-winhttp:$ktorVersion")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}

implementation("io.ktor:ktor-client-darwin:$ktorVersion")
}
}
val native2Main by getting {
dependencies {
implementation("io.ktor:ktor-client-darwin:$ktorVersion")
}
}
val native3Main by getting {
dependencies {
implementation("io.ktor:ktor-client-curl:$ktorVersion")
}
}
val native4Main by getting {
dependencies {
implementation("io.ktor:ktor-client-winhttp:$ktorVersion")
}
}
val nativeTest by getting
}
}

Expand All @@ -74,10 +79,10 @@ publishing {
publications {
publications.withType<MavenPublication> {
artifactId = when {
hostOs == "Mac OS X" && isArm64 -> artifactId.replace("native", "macosarm64")
hostOs == "Mac OS X" && !isArm64 -> artifactId.replace("native", "macosx64")
hostOs == "Linux" && !isArm64 -> artifactId.replace("native", "linuxx64")
isMingwX64 -> artifactId.replace("native", "mingwx64")
hostOs == "Mac OS X" && isArm64 -> artifactId.replace("native1", "macosarm64")
hostOs == "Mac OS X" && !isArm64 -> artifactId.replace("native2", "macosx64")
hostOs == "Linux" && !isArm64 -> artifactId.replace("native3", "linuxx64")
isMingwX64 -> artifactId.replace("native4", "mingwx64")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}.run { replace("kmp-", "") }
pom {
Expand Down

0 comments on commit e8dbef7

Please sign in to comment.