Skip to content

Commit 3e99683

Browse files
committed
Set up Maven Central releases
1 parent 211e0cb commit 3e99683

File tree

12 files changed

+135
-111
lines changed

12 files changed

+135
-111
lines changed

.github/workflows/gradle-publish.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
2-
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
1+
# This workflow will build a package using Gradle and then publish it to Maven Central when a release is published.
32

4-
name: Gradle Package
3+
name: Publish to Maven Central
54

65
on:
76
release:
@@ -16,13 +15,14 @@ jobs:
1615
packages: write
1716

1817
steps:
19-
- uses: actions/checkout@v4
18+
- name: Check out repo
19+
uses: actions/checkout@v4
20+
2021
- name: Set up JDK 17
2122
uses: actions/setup-java@v4
2223
with:
2324
java-version: '17'
2425
distribution: 'temurin'
25-
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
2626
cache: gradle
2727

2828
- name: Grant execute permission for gradlew
@@ -36,11 +36,10 @@ jobs:
3636
run: touch local.properties
3737
working-directory: android
3838

39-
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
40-
# the publishing section of your build.gradle
41-
- name: Publish to GitHub Packages
42-
run: ./gradlew publish
43-
working-directory: android
39+
- name: Publish to Maven Central
40+
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
4441
env:
45-
GITHUB_ACTOR: ${{ github.actor }}
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
43+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
44+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_SECRET_KEY }}
45+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if useLocalFramework {
1616
path: "./common/target/ios/libferrostar-rs.xcframework"
1717
)
1818
} else {
19-
let releaseTag = "0.7.2"
19+
let releaseTag = "0.8.0"
2020
let releaseChecksum = "b63a45c82d3b645d1367c7a5b700511a7c7803e4757afae5cff71ad4acb761c9"
2121
binaryTarget = .binaryTarget(
2222
name: "FerrostarCoreRS",

RELEASE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,18 @@ When cutting a release, follow this checklist:
77
3. Create a GitHub release and use the new version as the tag name (not that it must be in X.Y.Z format to please SPM).
88
4. Sit back and watch. GitHub actions take care of the rest.
99
Note that iOS CI ends up adding a commit due to the way binary checksumming works.
10+
11+
## GPG
12+
13+
Maven Central requires all packages to be signed.
14+
This necessarily means the headache of key management.
15+
Fortunately keys don't need to be regenerated very often,
16+
but here are some notes for whenever it's required again.
17+
18+
Sonatype has good [docs](https://central.sonatype.org/publish/requirements/gpg/) on generating a key.
19+
To export the private key for use in CI,
20+
you can run the following command.
21+
22+
```shell
23+
gpg --armor --export-secret-key you@example.com | grep -v '\-\-' | grep -v '^=.' | tr -d '\n'
24+
```

android/build.gradle

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,10 @@ plugins {
77
alias libs.plugins.ktfmt apply false
88
alias libs.plugins.paparazzi apply false
99
alias libs.plugins.compose.compiler apply false
10-
id 'maven-publish'
11-
}
12-
13-
publishing {
14-
repositories {
15-
maven {
16-
name = "GitHubPackages"
17-
url = uri("https://maven.pkg.github.com/stadiamaps/ferrostar")
18-
credentials {
19-
username = System.getenv("GITHUB_ACTOR")
20-
password = System.getenv("GITHUB_TOKEN")
21-
}
22-
}
23-
}
10+
alias libs.plugins.mavenPublish apply false
2411
}
2512

2613
allprojects {
2714
group = "com.stadiamaps.ferrostar"
28-
version = "0.7.2"
15+
version = "0.8.0"
2916
}

android/common-pom.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
ext {
2+
// Add an optional parameter includeGoogleRepo with a default value of false
3+
commonPomConfig = { pom, includeGoogleRepo = false ->
4+
pom.url = "https://github.com/stadiamaps/ferrostar"
5+
pom.inceptionYear = "2023"
6+
pom.licenses {
7+
license {
8+
name = "BSD-3-Clause"
9+
url = "https://spdx.org/licenses/BSD-3-Clause.html"
10+
}
11+
}
12+
pom.developers {
13+
developer {
14+
name = "Ian Wagner"
15+
organization = "Stadia Maps"
16+
organizationUrl = "https://stadiamaps.com/"
17+
}
18+
developer {
19+
name = "Jacob Fielding"
20+
organization = "Rallista"
21+
organizationUrl = "https://rallista.app/"
22+
}
23+
}
24+
pom.scm {
25+
connection = "scm:git:https://github.com/stadiamaps/ferrostar.git"
26+
developerConnection = "scm:git:ssh://github.com/stadiamaps/ferrostar.git"
27+
url = "http://github.com/stadiamaps/ferrostar"
28+
}
29+
30+
// Conditional inclusion of the Google repository
31+
if (includeGoogleRepo) {
32+
pom.withXml {
33+
def repo = asNode().appendNode('repositories').appendNode('repository')
34+
repo.appendNode('name', 'Google')
35+
repo.appendNode('id', 'google')
36+
repo.appendNode('url', 'https://maven.google.com/')
37+
}
38+
}
39+
}
40+
}

android/composeui/build.gradle

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import com.vanniktech.maven.publish.AndroidMultiVariantLibrary
2+
import com.vanniktech.maven.publish.SonatypeHost
3+
14
plugins {
25
alias libs.plugins.androidLibrary
36
alias libs.plugins.jetbrainsKotlinAndroid
47
alias libs.plugins.ktfmt
58
alias libs.plugins.paparazzi
69
alias libs.plugins.compose.compiler
10+
alias libs.plugins.mavenPublish
711
}
812

913
android {
@@ -34,12 +38,6 @@ android {
3438
buildFeatures {
3539
compose true
3640
}
37-
publishing {
38-
singleVariant('release') {
39-
withSourcesJar()
40-
withJavadocJar()
41-
}
42-
}
4341
}
4442

4543
dependencies {
@@ -69,21 +67,22 @@ dependencies {
6967
androidTestImplementation libs.androidx.test.espresso
7068

7169
implementation libs.androidx.compose.ui.tooling.preview
72-
debugImplementation libs.androidx.compose.ui.tooling
7370

71+
debugImplementation libs.androidx.compose.ui.tooling
7472
debugImplementation libs.androidx.compose.ui.test.manifest
7573
}
7674

77-
publishing {
78-
publications {
79-
"${project.name}-release"(MavenPublication) {
80-
groupId = 'com.stadiamaps.ferrostar'
81-
artifactId = 'composeui'
82-
version = project.version
75+
mavenPublishing {
76+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
77+
signAllPublications()
8378

84-
afterEvaluate {
85-
from components.release
86-
}
87-
}
79+
configure(new AndroidMultiVariantLibrary(true, true))
80+
81+
apply from: "${rootProject.projectDir}/common-pom.gradle"
82+
83+
pom {
84+
name = "Ferrostar Composable UI"
85+
description = "Composable non-map UI components for Ferrostar"
86+
commonPomConfig(it, true)
8887
}
89-
}
88+
}

android/core/build.gradle

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import com.vanniktech.maven.publish.AndroidMultiVariantLibrary
2+
import com.vanniktech.maven.publish.SonatypeHost
3+
14
plugins {
25
alias libs.plugins.androidLibrary
36
alias libs.plugins.jetbrainsKotlinAndroid
47
alias libs.plugins.cargo.ndk
58
alias libs.plugins.ktfmt
9+
alias libs.plugins.mavenPublish
610
}
711

812
android {
@@ -32,12 +36,6 @@ android {
3236
kotlinOptions {
3337
jvmTarget = '1.8'
3438
}
35-
publishing {
36-
singleVariant('release') {
37-
withSourcesJar()
38-
withJavadocJar()
39-
}
40-
}
4139
}
4240

4341
dependencies {
@@ -77,9 +75,10 @@ cargoNdk {
7775
}
7876

7977
android.libraryVariants.all { variant ->
78+
def bDir = layout.buildDirectory.dir("generated/source/uniffi/${variant.name}/java").get()
8079
def generateBindings = tasks.register("generate${variant.name.capitalize()}UniFFIBindings", Exec) {
8180
workingDir '../../common'
82-
commandLine 'cargo', 'run', '-p', 'uniffi-bindgen', 'generate', '--library', '../android/core/src/main/jniLibs/arm64-v8a/libferrostar.so', '--language', 'kotlin', '--out-dir', "${buildDir}/generated/source/uniffi/${variant.name}/java"
81+
commandLine 'cargo', 'run', '-p', 'uniffi-bindgen', 'generate', '--library', '../android/core/src/main/jniLibs/arm64-v8a/libferrostar.so', '--language', 'kotlin', '--out-dir', bDir
8382

8483
dependsOn "buildCargoNdk${variant.name.capitalize()}"
8584
}
@@ -103,20 +102,19 @@ android.libraryVariants.all { variant ->
103102
// to a good solution for forcing the directory to be marked as generated (short of checking in
104103
// project files, I suppose).
105104
// idea.module.generatedSourceDirs += file("${buildDir}/generated/source/uniffi/${variant.name}/java/uniffi")
106-
107-
sourceSet.java.srcDir 'src/main/java'
108105
}
109106

110-
publishing {
111-
publications {
112-
"${project.name}-release"(MavenPublication) {
113-
groupId = 'com.stadiamaps.ferrostar'
114-
artifactId = 'core'
115-
version = project.version
107+
mavenPublishing {
108+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
109+
signAllPublications()
116110

117-
afterEvaluate {
118-
from components.release
119-
}
120-
}
111+
configure(new AndroidMultiVariantLibrary(true, true))
112+
113+
apply from: "${rootProject.projectDir}/common-pom.gradle"
114+
115+
pom {
116+
name = "Ferrostar Core"
117+
description = "Core libray, models, and navigation business logic for Ferrostar"
118+
commonPomConfig(it)
121119
}
122120
}

android/gradle/libs.versions.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ agp = "8.5.2"
33
kotlin = "2.0.0"
44
cargo-ndk = "0.3.4"
55
ktfmt = "0.19.0"
6-
lifecycleRuntimeComposeAndroid = "2.8.3"
6+
androidx-lifecycle = "2.8.4"
77
paparazzi = "1.3.4"
88
desugar_jdk_libs = "2.0.4"
99
ktx = "1.13.1"
1010
kotlinx-coroutines = "1.8.1"
1111
kotlinx-datetime = "0.6.0"
1212
androidx-appcompat = "1.7.0"
13-
androidx-activity-compose = "1.9.0"
13+
androidx-activity-compose = "1.9.1"
1414
compose = "2024.06.00"
1515
okhttp = "4.12.0"
1616
moshi = "1.15.1"
@@ -20,6 +20,7 @@ junitVersion = "1.2.1"
2020
junitCompose = "1.6.8"
2121
espressoCore = "3.6.1"
2222
okhttp-mock = "2.0.0"
23+
mavenPublish = "0.29.0"
2324

2425
[libraries]
2526
desugar_jdk_libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar_jdk_libs" }
@@ -31,10 +32,10 @@ kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime",
3132
# AndroidX
3233
androidx-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "ktx" }
3334
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
34-
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx" }
35-
androidx-lifecycle-runtime-compose-android = { module = "androidx.lifecycle:lifecycle-runtime-compose-android", version.ref = "lifecycleRuntimeComposeAndroid" }
36-
androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx" }
37-
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose" }
35+
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" }
36+
androidx-lifecycle-runtime-compose-android = { module = "androidx.lifecycle:lifecycle-runtime-compose-android", version.ref = "androidx-lifecycle" }
37+
androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" }
38+
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
3839
# Jetpack Compose
3940
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidx-activity-compose" }
4041
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose" }
@@ -66,4 +67,5 @@ compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "
6667
androidLibrary = { id = "com.android.library", version.ref = "agp" }
6768
cargo-ndk = { id = "com.github.willir.rust.cargo-ndk-android", version.ref = "cargo-ndk" }
6869
ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" }
69-
paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
70+
paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
71+
mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }

android/maplibreui/build.gradle

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import com.vanniktech.maven.publish.AndroidMultiVariantLibrary
2+
import com.vanniktech.maven.publish.SonatypeHost
3+
14
plugins {
25
alias libs.plugins.androidLibrary
36
alias libs.plugins.jetbrainsKotlinAndroid
47
alias libs.plugins.ktfmt
58
alias libs.plugins.compose.compiler
9+
alias libs.plugins.mavenPublish
610
}
711

812
android {
@@ -33,12 +37,6 @@ android {
3337
buildFeatures {
3438
compose true
3539
}
36-
publishing {
37-
singleVariant('release') {
38-
withSourcesJar()
39-
withJavadocJar()
40-
}
41-
}
4240
}
4341

4442
dependencies {
@@ -66,19 +64,22 @@ dependencies {
6664
testImplementation libs.junit
6765
androidTestImplementation libs.androidx.test.junit
6866
androidTestImplementation libs.androidx.test.espresso
67+
6968
debugImplementation libs.androidx.compose.ui.test.manifest
7069
}
7170

72-
publishing {
73-
publications {
74-
"${project.name}-release"(MavenPublication) {
75-
groupId = 'com.stadiamaps.ferrostar'
76-
artifactId = 'maplibreui'
77-
version = project.version
71+
mavenPublishing {
72+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
73+
signAllPublications()
7874

79-
afterEvaluate {
80-
from components.release
81-
}
82-
}
75+
configure(new AndroidMultiVariantLibrary(true, true))
76+
77+
apply from: "${rootProject.projectDir}/common-pom.gradle"
78+
79+
pom {
80+
name = "Ferrostar MapLibre UI"
81+
description = "Composable map UI components for Ferrostar built with MapLibre"
82+
83+
commonPomConfig(it, true)
8384
}
8485
}

common/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/ferrostar/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ lints.workspace = true
22

33
[package]
44
name = "ferrostar"
5-
version = "0.7.2"
5+
version = "0.8.0"
66
readme = "README.md"
77
description = "The core of modern turn-by-turn navigation."
88
keywords = ["navigation", "routing", "valhalla", "osrm"]

0 commit comments

Comments
 (0)