Skip to content

Commit 6a7cab8

Browse files
wip Setup Publishing to Maven Central
1 parent ae55f4d commit 6a7cab8

File tree

4 files changed

+35
-118
lines changed

4 files changed

+35
-118
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,6 @@ on:
55
types: [published]
66

77
jobs:
8-
publish-swift:
9-
runs-on: macos-latest
10-
steps:
11-
- name: Setup JDK
12-
uses: actions/[email protected]
13-
with:
14-
java-version: 17
15-
- name: Checkout source
16-
uses: actions/checkout@v4
17-
- name: Cache build deps
18-
uses: actions/cache@v4
19-
with:
20-
path: |
21-
~/.gradle/wrapper
22-
~/.konan/cache
23-
~/.konan/dependencies
24-
key: build-deps-${{ runner.os }}-${{ hashFiles('gradle/**', 'gradlew*', 'gradle.properties', '*.gradle*') }}
25-
26-
- name: Build XCFrameworks
27-
run: ./gradlew assembleXCFramework
28-
29-
- name: Zip XCFramework
30-
uses: vimtor/action-zip@v1
31-
with:
32-
files: build/xcframework/
33-
dest: build/xcframework.zip
34-
35-
- name: Add release artifacts
36-
id: release_artifacts
37-
uses: softprops/action-gh-release@15d2aaca23625e5b2744248f7b68fc1e6bbff48e
38-
with:
39-
tag_name: ${{ github.event.release.tag_name }}
40-
files: |
41-
build/xcframework.zip
42-
43-
- name: Calculate checksums for XCFrameworks
44-
run: |
45-
cp Package.swift.template Package.swift
46-
echo RELEASE_CHECKSUM=$(swift package compute-checksum build/xcframework.zip) >> $GITHUB_ENV
47-
48-
- name: Checkout master
49-
uses: actions/checkout@v2
50-
with:
51-
ref: 'master'
52-
53-
- name: Update swift package
54-
run: |
55-
sed -e 's|RELEASE-URL|${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/xcframework.zip|;w Package.swift.tmp' Package.swift.template
56-
sed -e 's/RELEASE-CHECKSUM/${{ env.RELEASE_CHECKSUM }}/;w Package.swift' Package.swift.tmp
57-
58-
- name: Commit swift package
59-
run: |
60-
git config user.name "github-actions[bot]"
61-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
62-
git add Package.swift
63-
git commit -m "[CI] Update swift package"
64-
git tag swiftpm-${{ github.event.release.tag_name }}
65-
git push origin swiftpm-${{ github.event.release.tag_name }}
66-
678
publish-maven:
689
runs-on: macos-latest
6910

build.gradle.kts

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import org.apache.tools.ant.taskdefs.condition.Os
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
4+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
35

46
allprojects {
57
repositories {
@@ -12,22 +14,9 @@ allprojects {
1214

1315
plugins {
1416
alias(libs.plugins.kotlin.multiplatform)
15-
`maven-publish`
1617
alias(libs.plugins.kotlin.serialization)
1718
alias(libs.plugins.android.library)
18-
}
19-
20-
publishing {
21-
repositories {
22-
maven {
23-
name = "GitHubPackages"
24-
url = uri("https://maven.pkg.github.com/pebble-dev/libpebblecommon")
25-
credentials {
26-
username = System.getenv("GITHUB_ACTOR")
27-
password = System.getenv("GITHUB_TOKEN")
28-
}
29-
}
30-
}
19+
alias(libs.plugins.publish)
3120
}
3221

3322
android {
@@ -43,13 +32,11 @@ android {
4332
sourceCompatibility = JavaVersion.VERSION_11
4433
targetCompatibility = JavaVersion.VERSION_11
4534
}
46-
47-
kotlin {
48-
jvmToolchain(11)
49-
}
5035
}
5136

5237
kotlin {
38+
jvmToolchain(17)
39+
5340
android {
5441
publishLibraryVariants("release", "debug")
5542
}
@@ -127,6 +114,13 @@ kotlin {
127114
}
128115
}
129116

117+
tasks.withType<KotlinCompile>().configureEach {
118+
compilerOptions {
119+
jvmTarget = JvmTarget.JVM_11
120+
}
121+
}
122+
123+
130124
if (Os.isFamily(Os.FAMILY_MAC)) {
131125
val iosSimulatorFatFramework by tasks.registering(PlatformFatFramework::class) {
132126
onlyIf {
@@ -153,47 +147,8 @@ if (Os.isFamily(Os.FAMILY_MAC)) {
153147
inputFrameworks.setFrom(project.files(iosTask.outputFile))
154148
inputFrameworkDSYMs.setFrom(project.files(iosTask.outputFile.path+".dSYM"))
155149
}
156-
157-
val assembleXCFramework by tasks.registering {
158-
onlyIf {
159-
org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_MAC)
160-
}
161-
val deviceTask = tasks.getByName("iosDeviceFatFramework")
162-
val simulatorTask = tasks.getByName("iosSimulatorFatFramework")
163-
dependsOn(deviceTask)
164-
dependsOn(simulatorTask)
165-
outputs.dir(layout.buildDirectory.dir("xcframework")).withPropertyName("outputDir")
166-
167-
val outputPath = layout.buildDirectory.dir("xcframework").get().asFile.path + "/libpebblecommon.xcframework"
168-
169-
doLast {
170-
delete(outputPath)
171-
exec {
172-
commandLine (
173-
"xcodebuild", "-create-xcframework",
174-
"-framework", deviceTask.outputs.files.first { it.name == "libpebblecommon.framework" }.path,
175-
"-debug-symbols", deviceTask.outputs.files.first { it.name == "libpebblecommon.framework.dSYM" }.path,
176-
"-framework", simulatorTask.outputs.files.first { it.name == "libpebblecommon.framework" }.path,
177-
"-debug-symbols", simulatorTask.outputs.files.first { it.name == "libpebblecommon.framework.dSYM" }.path,
178-
"-output", outputPath
179-
)
180-
}
181-
}
182-
}
183150
}
184151

185-
/*project.afterEvaluate {
186-
tasks.withType(PublishToMavenRepository::class.java) {
187-
onlyIf {
188-
!publication.name.contains("ios")
189-
}
190-
}
191-
tasks.withType(Jar::class.java) {
192-
onlyIf {
193-
!name.contains("ios")
194-
}
195-
}
196-
}*/
197152

198153
abstract class PlatformFatFramework: DefaultTask() {
199154
@get:Input

gradle.properties

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,24 @@ version=0.1.27
55
org.gradle.jvmargs=-Xms128M -Xmx1G -XX:ReservedCodeCacheSize=200M
66
kotlin.native.binary.memoryModel=experimental
77
kotlin.mpp.androidSourceSetLayoutVersion=2
8-
kotlinVersion=2.0.0
9-
agpVersion=8.1.4
8+
9+
# Publishing
10+
SONATYPE_AUTOMATIC_RELEASE=true
11+
SONATYPE_HOST=DEFAULT
12+
RELEASE_SIGNING_ENABLED=true
13+
GROUP=io.rebble.libpebblecommon
14+
POM_ARTIFACT_ID=libpebblecommon
15+
VERSION_NAME=0.1.27
16+
POM_NAME=libpebblecommon
17+
POM_DESCRIPTION=A port/rewrite of libpebble2 for Kotlin multiplatform with additional features useful for watch companion apps.
18+
POM_INCEPTION_YEAR=2025
19+
POM_URL=https://github.com/pebble-dev/libpebblecommon
20+
POM_LICENCE_NAME=Apache-2.0
21+
POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0
22+
POM_LICENCE_DIST=repo
23+
POM_SCM_URL=https://github.com/pebble-dev/libpebblecommon
24+
POM_SCM_CONNECTION=scm:git:https://github.com/pebble-dev/libpebblecommon.git
25+
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/pebble-dev/libpebblecommon.git
26+
POM_DEVELOPER_ID=Rebble
27+
POM_DEVELOPER_NAME=Rebble
28+
POM_DEVELOPER_URL=https://rebble.io/

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ coroutine = "1.8.0"
77
uuid = "0.4.1"
88
serialization = "1.5.0"
99
kermit = "2.0.0-RC4"
10+
publish = "0.30.0"
1011

1112
[plugins]
1213
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
1314
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
1415
android-library = { id = "com.android.library", version.ref = "agp" }
16+
publish = { id = "com.vanniktech.maven.publish", version.ref = "publish"}
1517

1618
[libraries]
1719
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }

0 commit comments

Comments
 (0)