Skip to content

Commit d0fcf0b

Browse files
committed
Update publishing to central portal
1 parent 00835bd commit d0fcf0b

File tree

2 files changed

+65
-83
lines changed

2 files changed

+65
-83
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@ on: [push]
55
jobs:
66
compile:
77
runs-on: ubuntu-latest
8-
98
steps:
10-
- name: Checkout repo
11-
uses: actions/checkout@v3
12-
13-
- name: Set up Java
14-
id: setup-jre
15-
uses: actions/setup-java@v1
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-java@v3
1611
with:
17-
java-version: "11"
18-
architecture: x64
12+
java-version: '11'
13+
distribution: 'temurin'
1914

2015
- name: Compile
2116
run: ./gradlew compileJava
@@ -24,40 +19,39 @@ jobs:
2419
needs: [ compile ]
2520
runs-on: ubuntu-latest
2621
steps:
27-
- name: Checkout repo
28-
uses: actions/checkout@v3
29-
30-
- name: Set up Java
31-
id: setup-jre
32-
uses: actions/setup-java@v1
22+
- uses: actions/checkout@v3
23+
- uses: actions/setup-java@v3
3324
with:
34-
java-version: "11"
35-
architecture: x64
25+
java-version: '11'
26+
distribution: 'temurin'
3627

3728
- name: Test
3829
run: ./gradlew test
3930
env:
4031
TEST_SQUARE_TOKEN: ${{ secrets.TEST_SQUARE_TOKEN }}
32+
4133
publish:
4234
needs: [ compile ]
4335
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
4436
runs-on: ubuntu-latest
45-
4637
steps:
47-
- name: Checkout repo
48-
uses: actions/checkout@v3
49-
50-
- name: Set up Java
51-
id: setup-jre
52-
uses: actions/setup-java@v1
38+
- uses: actions/checkout@v3
39+
40+
- uses: actions/setup-java@v3
41+
with:
42+
java-version: '11'
43+
distribution: 'temurin'
44+
45+
- name: Import GPG key
46+
uses: crazy-max/ghaction-import-gpg@v5
5347
with:
54-
java-version: "11"
55-
architecture: x64
48+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
49+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
5650

57-
- name: Publish to maven
58-
run: |
59-
./gradlew publish
51+
- name: Publish to Maven Central
52+
run: ./gradlew publishAllPublicationsToMavenCentral
6053
env:
61-
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
62-
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
63-
MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/"
54+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
55+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_PORTAL_TOKEN }}
56+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
57+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}

build.gradle

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
plugins {
22
id 'java-library'
3-
id 'maven-publish'
43
id 'com.diffplug.spotless' version '6.11.0'
4+
id 'com.vanniktech.maven.publish' version '0.27.0'
55
}
66

77
repositories {
88
mavenCentral()
9-
maven {
10-
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
11-
}
129
}
1310

1411
dependencies {
@@ -20,7 +17,6 @@ dependencies {
2017
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2118
}
2219

23-
2420
sourceCompatibility = 1.8
2521
targetCompatibility = 1.8
2622

@@ -35,66 +31,58 @@ spotless {
3531
}
3632
}
3733

38-
39-
java {
40-
withSourcesJar()
41-
withJavadocJar()
42-
}
43-
44-
4534
group = 'com.squareup'
46-
4735
version = '45.0.0.20250618'
4836

49-
jar {
50-
dependsOn(":generatePomFileForMavenPublication")
51-
archiveBaseName = "square"
52-
}
53-
54-
sourcesJar {
55-
archiveBaseName = "square"
56-
}
57-
58-
javadocJar {
59-
archiveBaseName = "square"
60-
}
61-
6237
test {
6338
useJUnitPlatform()
6439
testLogging {
6540
showStandardStreams = true
6641
}
6742
}
6843

69-
publishing {
70-
publications {
71-
maven(MavenPublication) {
72-
groupId = 'com.squareup'
73-
artifactId = 'square'
74-
version = '45.0.0.20250618'
75-
from components.java
76-
pom {
77-
licenses {
78-
license {
79-
name = 'MIT'
80-
}
81-
}
82-
scm {
83-
connection = 'scm:git:git://github.com/square/square-java-sdk.git'
84-
developerConnection = 'scm:git:git://github.com/square/square-java-sdk.git'
85-
url = 'https://github.com/square/square-java-sdk'
86-
}
44+
// Configure maven publishing for Central Portal
45+
mavenPublishing {
46+
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL)
47+
signAllPublications()
48+
49+
coordinates("com.squareup", "square", "$version")
50+
51+
pom {
52+
name = "Square Java SDK"
53+
description = "Official Square Java SDK"
54+
inceptionYear = "2019"
55+
url = "https://github.com/square/square-java-sdk"
56+
57+
licenses {
58+
license {
59+
name = "MIT License"
60+
url = "https://opensource.org/licenses/MIT"
61+
distribution = "repo"
8762
}
8863
}
89-
}
90-
repositories {
91-
maven {
92-
url "$System.env.MAVEN_PUBLISH_REGISTRY_URL"
93-
credentials {
94-
username "$System.env.MAVEN_USERNAME"
95-
password "$System.env.MAVEN_PASSWORD"
64+
65+
developers {
66+
developer {
67+
id = "square"
68+
name = "Square"
69+
url = "https://github.com/square"
9670
}
9771
}
72+
73+
scm {
74+
url = "https://github.com/square/square-java-sdk"
75+
connection = "scm:git:git://github.com/square/square-java-sdk.git"
76+
developerConnection = "scm:git:ssh://[email protected]/square/square-java-sdk.git"
77+
}
9878
}
9979
}
10080

81+
java {
82+
withSourcesJar()
83+
withJavadocJar()
84+
85+
toolchain {
86+
languageVersion = JavaLanguageVersion.of(8)
87+
}
88+
}

0 commit comments

Comments
 (0)