Skip to content

Commit

Permalink
Merge pull request #9 from ioki-mobility/publishing
Browse files Browse the repository at this point in the history
Setup publishing
  • Loading branch information
StefMa authored Sep 15, 2023
2 parents 02cef5c + 19901a0 commit 84ac126
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 8 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Publish'

on:
push:
tags:
- '*'

jobs:
publish-kmp-metadata:
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 }}
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
uses: actions/checkout@v4

- name: Run tests
run: ./gradlew nativeTest
run: ./gradlew.bat nativeTest

- name: Test Report
uses: mikepenz/action-junit-report@v4
Expand Down
64 changes: 57 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
plugins {
kotlin("multiplatform") version "1.9.10"
kotlin("plugin.serialization") version "1.9.10"
`maven-publish`
}

group = "com.ioki.lokalise"
version = "0.0.1-SNAPSHOT"

repositories {
mavenCentral()
}

val hostOs = System.getProperty("os.name")
val isArm64 = System.getProperty("os.arch") == "aarch64"
val isMingwX64 = hostOs.startsWith("Windows")
kotlin {
jvm {
jvmToolchain(8)
Expand All @@ -21,9 +22,6 @@ kotlin {
}
}

val hostOs = System.getProperty("os.name")
val isArm64 = System.getProperty("os.arch") == "aarch64"
val isMingwX64 = hostOs.startsWith("Windows")
when {
hostOs == "Mac OS X" && isArm64 -> macosArm64("native")
hostOs == "Mac OS X" && !isArm64 -> macosX64("native")
Expand Down Expand Up @@ -59,7 +57,7 @@ kotlin {
dependencies {
when {
hostOs == "Mac OS X" -> implementation("io.ktor:ktor-client-darwin:$ktorVersion")
hostOs == "Linux"-> implementation("io.ktor:ktor-client-curl:$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.")
}
Expand All @@ -69,3 +67,55 @@ kotlin {
val nativeTest by getting
}
}

group = "com.ioki"
version = "0.0.1-SNAPSHOT"
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")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}.run { replace("kmp-", "") }
pom {
url.set("https://github.com/ioki-mobility/kmp-lokalise-api")
licenses {
license {
name.set("MIT License")
url.set("https://github.com/ioki-mobility/kmp-lokalise-api/blob/main/LICENSE")
}
}
organization {
name.set("ioki")
url.set("https://ioki.com")
}
developers {
developer {
name.set("Stefan 'StefMa' M.")
email.set("[email protected]")
url.set("https://StefMa.guru")
organization.set("ioki")
}
}
scm {
url.set("https://github.com/ioki-mobility/kmp-lokalise-api")
connection.set("https://github.com/ioki-mobility/kmp-lokalise-api.git")
developerConnection.set("[email protected]:ioki-mobility/kmp-lokalise-api.git")
}
}
}
}

repositories {
maven("https://maven.pkg.github.com/ioki-mobility/kmp-lokalise-api") {
name = "GitHubPackages"
credentials {
username = project.findProperty("githubPackagesUser") as? String
password = project.findProperty("githubPackagesKey") as? String
}
}
}
}

0 comments on commit 84ac126

Please sign in to comment.