Skip to content

Commit 0f544d5

Browse files
committed
feat: publish to maven central
1 parent f7e43a7 commit 0f544d5

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

.github/workflows/publish.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ jobs:
2727
run: ./gradlew :lib:publish
2828
env:
2929
RELEASE_VERSION: ${{ github.ref_name }}
30-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required for GitHub Packages
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For GitHub Packages
31+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} # For Central Portal
32+
CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }} # For Central Portal
33+
SIGNING_PRIVATE_KEY: ${{ secrets.SIGNING_PRIVATE_KEY }} # For Central Portal signing
34+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} # For Central Portal signing

lib/build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'maven-publish'
4+
id 'signing'
45
}
56

67
repositories {
@@ -42,11 +43,38 @@ publishing {
4243
pom {
4344
name = 'Kuberesolver'
4445
description = 'gRPC name resolver for Kubernetes'
46+
url = 'https://github.com/lothar1998/kuberesolver-java'
47+
licenses {
48+
license {
49+
name = 'The Apache License, Version 2.0'
50+
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
51+
}
52+
}
53+
developers {
54+
developer {
55+
id = 'lothar1998'
56+
name = 'Piotr Kuglin'
57+
58+
}
59+
}
60+
scm {
61+
connection = 'scm:git:git://github.com/lothar1998/kuberesolver-java.git'
62+
developerConnection = 'scm:git:ssh://[email protected]:lothar1998/kuberesolver-java.git'
63+
url = 'https://github.com/lothar1998/kuberesolver-java'
64+
}
4565
}
4666
}
4767
}
4868

4969
repositories {
70+
maven {
71+
name = "CentralPortal"
72+
url = uri("https://central.sonatype.com/api/v1/publisher")
73+
credentials {
74+
username = project.findProperty("central.user") ?: System.getenv("CENTRAL_USERNAME")
75+
password = project.findProperty("central.key") ?: System.getenv("CENTRAL_TOKEN")
76+
}
77+
}
5078
maven {
5179
name = "GitHubPackages"
5280
url = uri("https://maven.pkg.github.com/lothar1998/kuberesolver-java")
@@ -57,3 +85,15 @@ publishing {
5785
}
5886
}
5987
}
88+
89+
signing {
90+
sign publishing.publications.maven
91+
def privateKey = project.findProperty("signing.private_key") ?: System.getenv("SIGNING_PRIVATE_KEY")
92+
def signingPassword = project.findProperty("signing.password") ?: System.getenv("SIGNING_PASSWORD")
93+
94+
if (privateKey != null && signingPassword != null) {
95+
useInMemoryPgpKeys(privateKey, signingPassword)
96+
} else {
97+
println "Warning: GPG signing environment variables not found. Skipping signing."
98+
}
99+
}

0 commit comments

Comments
 (0)