Skip to content

Commit daf23eb

Browse files
committed
[PARP-155] Implement Maven Central publishing workflow
1 parent e0867c0 commit daf23eb

File tree

7 files changed

+101
-39
lines changed

7 files changed

+101
-39
lines changed

.github/workflows/deployment.yml

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
1-
name: Release - Deployment
1+
name: Publish to Maven Central
22

33
on:
4-
workflow_dispatch:
54
push:
65
tags:
7-
- release.*
6+
- 'release.[0-9]+.[0-9]+.[0-9]+'
87

98
jobs:
10-
deploy:
11-
name: Deployment
12-
runs-on: [ Linux ]
13-
env:
14-
ARTIFACTORY_URL: ${{secrets.MUDITA_ARTIFACTORY_OUTPUT_URL}}
15-
ARTIFACTORY_USERNAME: ${{secrets.MUDITA_ARTIFACTORY_USERNAME}}
16-
ARTIFACTORY_PASSWORD: ${{secrets.MUDITA_ARTIFACTORY_PASSWORD}}
9+
publish:
10+
runs-on: ubuntu-latest
11+
1712
steps:
18-
- name: Checkout
13+
- name: Checkout code
1914
uses: actions/checkout@v4
20-
with:
21-
fetch-depth: 100
2215

2316
- name: Set up JDK 17
24-
uses: actions/setup-java@v1
17+
uses: actions/setup-java@v4
2518
with:
26-
java-version: 17
19+
java-version: '17'
20+
distribution: 'temurin'
21+
22+
- name: Validate version consistency
23+
run: |
24+
TAG_VERSION=${GITHUB_REF#refs/tags/release.}
25+
GRADLE_VERSION=$(grep "library.version=" gradle.properties | cut -d'=' -f2)
26+
27+
echo "Tag version: $TAG_VERSION"
28+
echo "Gradle version: $GRADLE_VERSION"
29+
30+
if [ "$TAG_VERSION" != "$GRADLE_VERSION" ]; then
31+
echo "Error: Tag version ($TAG_VERSION) doesn't match gradle.properties version ($GRADLE_VERSION)"
32+
exit 1
33+
fi
34+
35+
echo "Version consistency validated"
36+
37+
- name: Grant execute permission for gradlew
38+
run: chmod +x gradlew
2739

28-
- name: Setup Android SDK
29-
uses: android-actions/setup-android@v3
40+
- name: Build release
41+
run: ./gradlew assembleRelease --no-daemon --stacktrace
3042

31-
- name: Lint kotlin check
32-
timeout-minutes: 5
33-
run: ./gradlew ktlintCheck
43+
- name: Create signing key file
44+
run: echo "${{ secrets.SIGNING_KEY }}" | base64 -d > secring.gpg
3445

35-
- name: Full build
36-
timeout-minutes: 5
37-
run: ./gradlew clean build
46+
- name: Publish to Maven Central
47+
env:
48+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
49+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
50+
ORG_GRADLE_PROJECT_signing.keyId: ${{ secrets.SIGNING_KEY_ID }}
51+
ORG_GRADLE_PROJECT_signing.password: ${{ secrets.SIGNING_PASSWORD }}
52+
run: ./gradlew publishToMavenCentral --no-daemon --stacktrace
3853

39-
- name: Deploy artifactory
40-
timeout-minutes: 5
41-
run: ./gradlew publish
54+
- name: Clean up
55+
if: always()
56+
run: rm -f secring.gpg

.github/workflows/library-bump.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
jobs:
1616
check:
1717
name: Check Version Bump
18-
runs-on: [ Linux ]
18+
runs-on: ubuntu-latest
1919
if: github.event_name == 'pull_request'
2020

2121
steps:

.github/workflows/pull-request-android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
jobs:
1616
test:
1717
name: Lint - Android
18-
runs-on: [ Linux ]
18+
runs-on: ubuntu-latest
1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ google-services.json
3333
*.hprof
3434

3535
.DS_Store
36+
37+
secring.gpg

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ library.namespace=com.mudita.mmd
1212
library.compileSdk=34
1313
library.minSdk=28
1414
library.targetSdk=34
15-
library.version=1.0.0
15+
library.version=1.0.1

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ compose = "1.7.3"
88
material3 = "1.3.1"
99
activity-compose = "1.10.1"
1010
dokka = "2.0.0"
11+
maven = "0.34.0"
1112

1213
[libraries]
1314
ktlint = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint" }
@@ -23,3 +24,4 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
2324
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
2425
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
2526
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
27+
maven-publish = {id = "com.vanniktech.maven.publish", version.ref = "maven" }

mmd-core/build.gradle.kts

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,53 @@ plugins {
44
alias(libs.plugins.compose)
55
alias(libs.plugins.compose.compiler)
66
alias(libs.plugins.dokka)
7-
`maven-publish`
7+
alias(libs.plugins.maven.publish)
8+
id("signing")
89
}
910

10-
group = properties["library.group"].toString()
11-
version =
12-
run {
13-
System.getenv("GITHUB_REF_NAME")?.removePrefix("release.")
14-
?: properties["library.version"].toString()
15-
}
16-
1711
kotlin {
1812
androidTarget {
19-
mavenPublication {
20-
artifactId = properties["library.artifactId"].toString()
13+
mavenPublishing {
14+
publishToMavenCentral()
15+
signAllPublications()
16+
17+
coordinates(
18+
groupId = properties["library.group"].toString(),
19+
artifactId = properties["library.artifactId"].toString(),
20+
version = properties["library.version"].toString()
21+
)
22+
23+
pom {
24+
name.set("Mudita MMD Library")
25+
description.set(
26+
"A UI component library optimized for e‑ink displays on Android, " +
27+
"built on top of Jetpack Compose Material 3 guidelines and classes. " +
28+
"Our goal is to provide a consistent, " +
29+
"predictable set of components that respects Material Design " +
30+
"while addressing the specifics of e‑ink displays.",
31+
)
32+
inceptionYear.set("2025")
33+
url.set("https://github.com/mudita/MMD")
34+
licenses {
35+
license {
36+
name.set("The Apache License, Version 2.0")
37+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
38+
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
39+
}
40+
}
41+
developers {
42+
developer {
43+
id.set("krystianbroniszewskimudita")
44+
name.set("Krystian Broniszewski")
45+
email.set("[email protected]")
46+
}
47+
}
48+
scm {
49+
connection.set("scm:git:github.com/mudita/MMD.git")
50+
developerConnection.set("scm:git:ssh://github.com/mudita/MMD.git")
51+
url.set("https://github.com/mudita/MMD/tree/main")
52+
}
53+
}
2154
}
2255

2356
publishLibraryVariants("release")
@@ -64,3 +97,13 @@ android {
6497
}
6598
}
6699
}
100+
101+
signing {
102+
val keyFile = rootProject.file("secring.gpg")
103+
val password = project.findProperty("signing.password") as? String
104+
105+
if (keyFile.exists() && password != null) {
106+
useInMemoryPgpKeys(keyFile.readText(), password)
107+
sign(publishing.publications)
108+
}
109+
}

0 commit comments

Comments
 (0)