Skip to content

Commit 01b9e87

Browse files
committed
feat: add maven publishing
1 parent e189fbf commit 01b9e87

File tree

6 files changed

+153
-9
lines changed

6 files changed

+153
-9
lines changed

.github/workflows/publish.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: publish
2+
run-name: "Publish"
3+
on:
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
build-app:
9+
runs-on: "ubuntu-latest"
10+
env:
11+
BUILD_NUMBER: ${{ github.run_number }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
# Determine new version
18+
19+
- name: Collect version prerequisites
20+
shell: bash
21+
run: |
22+
OLD_VERSION=$(cat version.txt)
23+
echo "OLD_VERSION=$OLD_VERSION" >> $GITHUB_ENV
24+
echo "PREV_VERSION_REF=$(git rev-list -n 1 $OLD_VERSION)" >> $GITHUB_ENV
25+
- name: Check if there were any new fix or feature commits
26+
id: version-check
27+
uses: inovait/actions-common/bump-version@v11
28+
with:
29+
version: '${{ env.OLD_VERSION }}'
30+
from: '${{ env.PREV_VERSION_REF }}'
31+
to: 'HEAD'
32+
increment: "auto"
33+
- run: "echo \"No feature or fix commits. Skipping build...\""
34+
if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}"
35+
- uses: andymckay/cancel-action@0.3
36+
if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}"
37+
- name: "Wait for cancel to stick"
38+
run: "sleep 99999"
39+
if: "${{ steps.version-check.outputs.version == env.OLD_VERSION }}"
40+
- run: "./config/bump-version.sh ${{ steps.version-check.outputs.version }}"
41+
- run: "v=$(cat version.txt);echo \"VERSION=$v\" > $GITHUB_ENV"
42+
- run: "echo \"# Release version ${{ env.VERSION }}\" > $GITHUB_STEP_SUMMARY"
43+
44+
# Build preparations
45+
- uses: actions/setup-java@v4
46+
with:
47+
java-version: '21'
48+
distribution: temurin
49+
cache: gradle
50+
- name: Setup Android SDK
51+
uses: android-actions/setup-android@7c5672355aaa8fde5f97a91aa9a99616d1ace6bc
52+
- name: Validate Gradle Wrapper
53+
uses: gradle/actions/wrapper-validation@ac638b010cf58a27ee6c972d7336334ccaf61c96
54+
- name: Compile library
55+
run: "./gradlew --parallel assemble"
56+
- name: Lint
57+
run: "./gradlew --continue --parallel lintDebug detektMain detektTest buildHealth reportMerge detektReleaseUnitTest -x detektRelease --continue"
58+
- name: Generate Changelog
59+
id: changelog
60+
uses: inovait/actions-common/git-changelog-generator@v8
61+
with:
62+
git_commit_url_prefix: 'https://github.com/pebble-dev/PebbleKitAndroid2/commit/'
63+
from: '${{ env.PREV_VERSION_REF }}'
64+
to: 'HEAD'
65+
# - name: 'Publish'
66+
# run: './gradlew publishToMavenCentral --no-configuration-cache
67+
# env:
68+
# ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
69+
# ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
70+
# ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
71+
# ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_SIGNING_ID }}
72+
# ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SIGNING_PASSPHRASE }}
73+
- name: 'Add changelog and version'
74+
run: 'git add version.txt'
75+
- run: 'git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"'
76+
- run: 'git config --global user.name "github-actions[bot]"'
77+
- name: 'Commit changelog and version'
78+
run: 'git commit -m "chore: release ${{ env.VERSION }}"'
79+
- name: 'Push changelog and version'
80+
run: 'git push'
81+
- name: 'Create tag'
82+
run: 'git tag ${{ env.VERSION }}'
83+
- name: 'Push tag'
84+
run: 'git push origin ${{ env.VERSION }}'
85+
- name: Create a Release
86+
uses: ncipollo/release-action@v1
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
with:
90+
name: ${{ env.VERSION }}
91+
tag: ${{ env.VERSION }}
92+
body: ${{ steps.changelog.outputs.changelog }}
93+
- name: Publish Test Results
94+
uses: EnricoMi/publish-unit-test-result-action/composite@v2
95+
if: always()
96+
with:
97+
comment_mode: failures
98+
junit_files: |
99+
**/build/outputs/*-results/**/*.xml
100+
**/build/*-results/**/*.xml

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies {
3030
implementation(libs.android.agp)
3131
implementation(libs.detekt.plugin)
3232
implementation(libs.dependencyAnalysis)
33+
implementation(libs.dokka)
3334
implementation(libs.kotlin.plugin)
3435
implementation(libs.kotlinova.gradle)
3536
implementation(libs.mavenPublish)
Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,50 @@
1+
import gradle.kotlin.dsl.accessors._df438b9d261df97d39394f67dfadf160.mavenPublishing
2+
3+
14
plugins {
25
id("com.vanniktech.maven.publish")
6+
id("org.jetbrains.dokka")
37
}
48

5-
// No javadoc for now
6-
// https://github.com/Kotlin/dokka/issues/2956
7-
tasks
8-
.matching { task ->
9-
task.name.contains("javaDocReleaseGeneration") ||
10-
task.name.contains("javaDocDebugGeneration")
11-
}.configureEach {
12-
enabled = false
9+
group = "io.rebble.pebblekit2"
10+
version = File(rootDir, "version.txt").readText().trim()
11+
12+
mavenPublishing {
13+
publishToMavenCentral(automaticRelease = true)
14+
15+
if (System.getenv("ORG_GRADLE_PROJECT_signingInMemoryKey") != null) {
16+
signAllPublications()
1317
}
18+
19+
pom {
20+
val projectGitUrl = "https://github.com/pebble-dev/PebbleKitAndroid2"
21+
name.set(project.name)
22+
description.set(
23+
"A new modern PebbleKit API for communication between phone companion apps and " +
24+
"the watchapps on the Pebble-OS running watches."
25+
)
26+
url.set(projectGitUrl)
27+
inceptionYear.set("2025")
28+
licenses {
29+
license {
30+
name.set("Apache License 2.0")
31+
url.set("$projectGitUrl/blob/main/LICENSE")
32+
}
33+
}
34+
issueManagement {
35+
system.set("GitHub")
36+
url.set("$projectGitUrl/issues")
37+
}
38+
scm {
39+
connection.set("scm:git:$projectGitUrl")
40+
developerConnection.set("scm:git:$projectGitUrl")
41+
url.set(projectGitUrl)
42+
}
43+
developers {
44+
developer {
45+
name.set("Rebble")
46+
url.set("https://rebble.io/")
47+
}
48+
}
49+
}
50+
}

config/bump-version.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
echo "Bumping version to $1"
2+
3+
echo "$1" > version.txt

config/libs.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ androidx-compose-runtime = "1.9.2"
88
androidx-core = "1.17.0"
99
androidx-datastore = "1.1.7"
1010
dependencyAnalysis = "3.0.4"
11+
dokka = "2.1.0"
1112
detekt = "1.23.8"
1213
detekt-compilerWarnings = "0.0.4"
1314
kermit = "2.0.4"
14-
mavenPublish = "0.35.0"
15+
mavenPublish = "0.36.0"
1516
kotlin = "2.2.20"
1617
kotlin-coroutines = "1.10.2"
1718
kotlinova = "4.0.0-alpha07"
@@ -33,6 +34,7 @@ dependencyAnalysis = { module = "com.autonomousapps:dependency-analysis-gradle-p
3334
detekt-compilerWarnings = { module = "com.braisgabin.detekt:kotlin-compiler-wrapper", version.ref = "detekt-compilerWarnings" }
3435
detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
3536
detekt-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
37+
dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
3638
kermit = { module = "co.touchlab:kermit", version.ref = "kermit" }
3739
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" }
3840
kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.9

0 commit comments

Comments
 (0)