Skip to content

Commit

Permalink
Publish SPM (#7)
Browse files Browse the repository at this point in the history
Co-authored-by: Noor Dawod <[email protected]>
Co-authored-by: Noor Dawod <[email protected]>
Co-authored-by: Ståle Storø Hauknes <[email protected]>
  • Loading branch information
4 people authored May 8, 2024
1 parent 736c8bd commit 25f1b33
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 37 deletions.
9 changes: 9 additions & 0 deletions .github/actions/java/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: "Set up Adopt OpenJDK 17"

runs:
using: "composite"
steps:
- uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
13 changes: 13 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Lint code"

runs:
using: "composite"
steps:
- name: "Set up Adopt OpenJDK 17"
uses: ./.github/actions/java
- name: "Run Detekt"
shell: sh
run: sh gradlew detekt
- name: "Run KtLint"
shell: sh
run: sh gradlew ktlintCheck
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Lint and build code"

on:
push:
branches:
- "**"
- "!main"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: "Clone code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Lint code"
uses: ./.github/actions/lint

build:
needs: lint
runs-on: macos-latest
steps:
- name: "Clone code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Set up Adopt OpenJDK 17"
uses: ./.github/actions/java
- name: "Validate Gradle wrapper"
uses: gradle/wrapper-validation-action@v1
- name: "Build code"
shell: sh
run: sh gradlew build
55 changes: 36 additions & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
name: Publish
name: "Lint and build code, and publish artifacts to repository"

on:
create:
tags:
- '^[0-9]+\.[0-9]+\.[0-9]+$'
push:
branches:
- "main"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: "Clone code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Lint code"
uses: ./.github/actions/lint

build:
needs: lint
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: "Clone code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Adopt OpenJDK 17
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 17
- name: Validate Gradle wrapper
- name: "Set up Adopt OpenJDK 17"
uses: ./.github/actions/java
- name: "Validate Gradle wrapper"
uses: gradle/wrapper-validation-action@v1
- name: Publish to GitHub Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_ACCESS_TOKEN_READ_PACKAGES: ${{ secrets.ACCESS_TOKEN_READ_PACKAGES }}
shell: sh
run: |
sh gradlew --no-daemon publishAllPublicationsToAirthingsGitHubPackagesRepository

publish:
needs: build
permissions:
contents: write
packages: write
uses: touchlab/KMMBridgeGithubWorkflow/.github/workflows/[email protected]
with:
runsOn: "macOS-14"
jvmVersion: 17
versionBaseProperty: LIBRARY_VERSION
publishTask: kmmBridgePublish publishAllPublicationsToGitHubPackagesRepository
secrets:
gradle_params: -PGITHUB_PUBLISH_USER=${{ secrets.GITHUB_ACTOR }} -PGITHUB_PUBLISH_TOKEN=${{ secrets.GITHUB_TOKEN }} -PGITHUB_REPO=https://github.com/Airthings/KmpLog.git
47 changes: 30 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

rootProject.group = "com.airthings.lib"
rootProject.version = "0.2.6"
private val version = (properties["AUTO_VERSION"] ?: properties["LIBRARY_VERSION"])?.toString()
?: error("Fatal error: unable to determine the library version.")

private val iosFrameworkName = "KmpLog"

rootProject.group = "${properties["GROUP"]}"
rootProject.version = version

buildscript {
repositories {
Expand Down Expand Up @@ -52,6 +57,7 @@ plugins {
id("com.github.ben-manes.versions")
id("com.android.library")
id("maven-publish")
id("co.touchlab.kmmbridge")
}

dependencies {
Expand Down Expand Up @@ -105,7 +111,7 @@ kotlin {
linkerOpts += "-ld64"
}
it.binaries.framework {
baseName = rootProject.name
baseName = iosFrameworkName
}
}

Expand All @@ -120,6 +126,15 @@ kotlin {
}
}

// See for details: https://youtrack.jetbrains.com/issue/KT-61573
targets.all {
compilations.all {
compilerOptions.configure {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}

sourceSets {
val commonMain by getting {
dependencies {
Expand Down Expand Up @@ -170,18 +185,16 @@ android {
}
}

publishing {
repositories {
mavenLocal()
maven {
name = "AirthingsGitHubPackages"
url = uri("https://maven.pkg.github.com/airthings/kmplog")

credentials {
// The following are automatically generated by GitHub.
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
kmmbridge {
frameworkName.set(iosFrameworkName)
mavenPublishArtifacts()
spm(
spmDirectory = "./",
swiftToolVersion = "5.9",
targetPlatforms = {
iOS { v("15") }
},
)
}

addGithubPackagesRepository()
9 changes: 8 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

# Versioning:
# Note 1: KMMBridge manages the patch number automatically, so please leave it out below.
# Note 2: Bump up the minor version when big changes happen, otherwise leave the version intact.
GROUP=com.airthings.lib
LIBRARY_VERSION=0.2

# Gradle/KMP options:
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
kotlin.code.style=official
Expand All @@ -42,9 +48,10 @@ version.plugin.androidGradle=8.1.2
version.plugin.ktlintGradle=11.6.1
version.plugin.detekt=1.23.3
version.plugin.outdated=0.49.0
version.plugin.kmmbridge=0.5.5

# Dependencies:
version.kotlin=1.9.22
version.kotlin=1.9.23
version.kotlin.coroutines=1.7.3
version.kotlin.datetime=0.4.1
version.stately.concurrency=1.2.3
Empty file modified gradlew
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pluginManagement {
"org.jlleitschuh.gradle.ktlint" -> useVersion("${props["version.plugin.ktlintGradle"]}")
"com.github.ben-manes.versions" -> useVersion("${props["version.plugin.outdated"]}")
"com.android.library" -> useVersion("${props["version.plugin.androidGradle"]}")
"co.touchlab.kmmbridge" -> useVersion("${props["version.plugin.kmmbridge"]}")
}
}
}
Expand Down

0 comments on commit 25f1b33

Please sign in to comment.