Skip to content

Commit a38446a

Browse files
committed
Updated publishing
1 parent 5ddefc9 commit a38446a

File tree

6 files changed

+319
-226
lines changed

6 files changed

+319
-226
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build & Publish
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- "v*"
77

88
jobs:
99
build:
@@ -65,7 +65,22 @@ jobs:
6565
esac
6666
6767
- name: Build jpostal
68-
run: ./gradlew -Pversion=${{ github.event.release.tag_name }} clean build platformJar -x test
68+
run: ./gradlew -Pversion=${{ github.event.release.tag_name }} clean build platformJar -x test -x signArchives
69+
70+
- name: Verify JAR contents
71+
run: |
72+
echo "=== Built JARs ==="
73+
ls -la build/libs/
74+
echo "=== JAR Contents ==="
75+
for jar in build/libs/jpostal-*.jar; do
76+
if [[ -f "$jar" && "$jar" != *"sources"* && "$jar" != *"javadoc"* ]]; then
77+
echo "Contents of $jar:"
78+
jar -tf "$jar" | grep -E "(native/|\.class$)" | head -10
79+
echo "Native libraries:"
80+
jar -tf "$jar" | grep native/ || echo "No native libraries found"
81+
echo "---"
82+
fi
83+
done
6984
7085
- name: Upload platform artifacts
7186
uses: actions/upload-artifact@v4
@@ -91,32 +106,46 @@ jobs:
91106
- name: Setup Java
92107
uses: actions/setup-java@v5
93108
env:
94-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
109+
GPG_PASSPHRASE: ${{ secrets.SIGNING_KEY_PASSPHRASE }}
95110
with:
96111
distribution: temurin
97112
java-version: 21
98113
cache: gradle
99114
gpg-passphrase: GPG_PASSPHRASE
100-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
115+
gpg-private-key: ${{ secrets.SIGNING_KEY }}
101116

102117
- name: Setup Gradle
103118
uses: gradle/actions/setup-gradle@v4
104119

105-
- name: Prepare artifacts for publishing
120+
- name: List downloaded artifacts
106121
run: |
107-
mkdir -p build/libs
108-
find artifacts -name "*.jar" -exec cp {} build/libs/ \;
109-
ls -la build/libs/
122+
echo "Downloaded artifacts:"
123+
find artifacts -name "*.jar" -type f
110124
111-
- name: Publish
125+
- name: Build for publishing
126+
run: |
127+
# Build the universal JAR (signing handled by Maven Central plugin)
128+
./gradlew clean build -x test
129+
130+
- name: Publish to Maven Central
112131
env:
113-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
114-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
115-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116-
run: ./gradlew publish
132+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
133+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
134+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
135+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ vars.SIGNING_KEY_ID }}
136+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSPHRASE }}
137+
run: ./gradlew publishToMavenCentral
138+
139+
- name: Prepare release artifacts
140+
run: |
141+
mkdir -p release-artifacts
142+
# Copy the universal JAR
143+
cp build/libs/*.jar release-artifacts/
144+
# Copy platform-specific JARs from artifacts
145+
find artifacts -name "*.jar" -type f -exec cp {} release-artifacts/ \;
117146
118147
- name: Create GitHub Release
119148
uses: softprops/action-gh-release@v2
120149
with:
121-
files: build/libs/*.jar
150+
files: release-artifacts/*.jar
122151
generate_release_notes: true

build.gradle

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
id 'application'
66
id 'signing'
77
id 'maven-publish'
8+
id "com.vanniktech.maven.publish" version "0.34.0"
89
}
910

1011
group = 'com.matchory.packages'
@@ -29,8 +30,6 @@ repositories {
2930
java {
3031
sourceCompatibility = JavaVersion.VERSION_21
3132
targetCompatibility = JavaVersion.VERSION_21
32-
withJavadocJar()
33-
withSourcesJar()
3433
}
3534

3635
sourceSets.main.java.srcDirs = ["src/main/java"]
@@ -112,8 +111,8 @@ tasks.processResources {
112111
def buildArch = System.getProperty("os.arch").toLowerCase()
113112
def isCrossCompiling = (currentOs != buildOs) || (currentArch != buildArch)
114113

115-
if (!isCrossCompiling && file("${buildDir}/libs/jpostal/shared").exists()) {
116-
from("${buildDir}/libs/jpostal/shared") {
114+
if (!isCrossCompiling && file("${rootProject.layout.buildDirectory}/libs/jpostal/shared").exists()) {
115+
from("${rootProject.layout.buildDirectory}/libs/jpostal/shared") {
117116
include '*.so', '*.dylib', '*.dll'
118117
into("native")
119118
rename { filename ->
@@ -193,8 +192,8 @@ jar {
193192
def buildOsFolder = buildOs.contains("mac") ? "macos" : "linux"
194193
def buildArchFolder = buildArch.contains("aarch64") || buildArch.contains("arm") ? "aarch64" : "x86_64"
195194

196-
if (file("${buildDir}/libs/jpostal/shared").exists()) {
197-
from("${buildDir}/libs/jpostal/shared") {
195+
if (file("${rootProject.layout.buildDirectory}/libs/jpostal/shared").exists()) {
196+
from("${rootProject.layout.buildDirectory}/libs/jpostal/shared") {
198197
include '*.so', '*.dylib', '*.dll'
199198
into("native/${buildOsFolder}/${buildArchFolder}")
200199
rename { filename ->
@@ -223,89 +222,63 @@ jar {
223222
}
224223

225224
application {
226-
applicationDefaultJvmArgs = ["-Djava.library.path=" + file("${buildDir}/libs/jpostal/shared").absolutePath]
225+
applicationDefaultJvmArgs = ["-Djava.library.path=" + file("${rootProject.layout.buildDirectory}/libs/jpostal/shared").absolutePath]
227226
}
228227

229228
dependencies {
230229
testImplementation 'junit:junit:4.+'
231230
}
232231

233232
tasks.withType(Test).configureEach {
234-
systemProperty "java.library.path", file("${buildDir}/libs/jpostal/shared").absolutePath
233+
systemProperty "java.library.path", file("${rootProject.layout.buildDirectory}/libs/jpostal/shared").absolutePath
235234
}
236235

237-
artifacts {
238-
archives javadocJar, sourcesJar
239-
}
240-
241-
publishing {
242-
publications {
243-
mavenJava(MavenPublication) {
244-
groupId = 'com.matchory.packages'
245-
artifactId = 'jpostal'
246-
version = '1.0.0'
236+
mavenPublishing {
237+
coordinates("com.matchory.packages", "jpostal", getProperty("version").toString().replaceFirst("^v", ""))
238+
publishToMavenCentral()
247239

248-
from components.java
240+
// Configure signing - try in-memory first, fall back to file-based
241+
if (project.hasProperty("signingInMemoryKey") || project.hasProperty("signing.keyId")) {
242+
signAllPublications()
243+
}
249244

250-
versionMapping {
251-
usage('java-api') {
252-
fromResolutionOf('runtimeClasspath')
253-
}
254-
usage('java-runtime') {
255-
fromResolutionResult()
256-
}
245+
pom {
246+
name = 'jpostal'
247+
description = 'Java/JNI bindings to libpostal for fast international street address parsing/normalization'
248+
url = 'https://github.com/matchory/jpostal'
249+
developers {
250+
developer {
251+
id = 'openvenues'
252+
name = 'Open Venues'
253+
url = 'https://github.com/openvenues'
257254
}
258-
259-
pom {
260-
name = 'jpostal'
261-
description = 'Java/JNI bindings to libpostal for fast international street address parsing/normalization'
262-
url = 'https://github.com/matchory/jpostal'
263-
developers {
264-
developer {
265-
id = 'openvenues'
266-
name = 'Open Venues'
267-
url = 'https://github.com/openvenues'
268-
}
269-
developer {
270-
id = 'matchory'
271-
name = 'Matchory GmbH'
272-
url = 'https://github.com/matchory'
273-
}
274-
}
275-
licenses {
276-
license {
277-
name = 'MIT'
278-
}
279-
}
280-
scm {
281-
connection = 'scm:git:git://github.com/matchory/libpostal.git'
282-
developerConnection = 'scm:git:ssh://github.com/matchory/libpostal.git'
283-
url = 'https://github.com/matchory/libpostal'
284-
}
255+
developer {
256+
id = 'matchory'
257+
name = 'Matchory GmbH'
258+
url = 'https://github.com/matchory'
285259
}
286260
}
287-
}
288-
289-
repositories {
290-
maven {
291-
name = 'com.matchory.packages.jpostal'
292-
url = layout.buildDirectory.dir("repo")
293-
}
294-
maven {
295-
name = "GitHubPackages"
296-
url = "https://maven.pkg.github.com/matchory/jpostal"
297-
credentials {
298-
username = System.getenv("GITHUB_ACTOR")
299-
password = System.getenv("GITHUB_TOKEN")
261+
licenses {
262+
license {
263+
name = 'MIT'
300264
}
301265
}
266+
scm {
267+
connection = 'scm:git:git://github.com/matchory/libpostal.git'
268+
developerConnection = 'scm:git:ssh://github.com/matchory/libpostal.git'
269+
url = 'https://github.com/matchory/libpostal'
270+
}
302271
}
303272
}
304273

305-
signing {
306-
sign configurations.archives
307-
sign publishing.publications.mavenJava
308-
}
274+
//signing {
275+
// required {
276+
// gradle.taskGraph.hasTask("publish") &&
277+
// (project.hasProperty("signing.keyId") || System.getenv("GPG_PRIVATE_KEY") != null)
278+
// }
279+
// sign configurations.archives
280+
// sign publishing.publications.mavenJava
281+
//}
309282

310283
javadoc {
311284
if (JavaVersion.current().isJava9Compatible()) {

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.configuration-cache=true

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)