Skip to content

Commit 8997e52

Browse files
deploy to central.sonatype.com
1 parent 4f0e15e commit 8997e52

File tree

2 files changed

+50
-40
lines changed

2 files changed

+50
-40
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
name: Build
22
on:
33
[push]
4+
5+
env:
6+
JAVA_VERSION: 21
7+
48
jobs:
59
build:
610
name: Build
711
runs-on: ubuntu-latest
8-
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
12+
permissions:
13+
id-token: write # Required for the attestations step
14+
contents: write # Required for the release step
15+
attestations: write # Required for the attestations step
16+
packages: write # Required for the deploy to GitHub Packages step
917
steps:
1018
- uses: actions/checkout@v4
1119
with:
1220
fetch-depth: 0
13-
- uses: actions/setup-java@v3
21+
- uses: actions/setup-java@v4
1422
with:
15-
java-version: 21
23+
java-version: ${{ env.JAVA_VERSION }}
1624
distribution: temurin
1725
cache: 'maven'
26+
server-id: central
27+
server-username: MAVEN_CENTRAL_USERNAME
28+
server-password: MAVEN_CENTRAL_PASSWORD
1829
gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
1930
gpg-passphrase: MAVEN_GPG_PASSPHRASE
31+
2032
- name: Cache SonarCloud packages
2133
uses: actions/cache@v3
2234
with:
2335
path: ~/.sonar/cache
2436
key: ${{ runner.os }}-sonar
2537
restore-keys: ${{ runner.os }}-sonar
38+
2639
- name: Build and Test
2740
run: >
28-
mvn -B verify
41+
mvn -B verify --no-transfer-progress
2942
jacoco:report
3043
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
3144
-Pcoverage
@@ -35,35 +48,43 @@ jobs:
3548
env:
3649
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
3750
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38-
- name: Deploy to GitHub Packages
51+
52+
- name: Deploy to Maven Central
3953
if: startsWith(github.ref, 'refs/tags/')
40-
run: mvn -B deploy -Psign,deploy-github -DskipTests --no-transfer-progress
54+
run: mvn -B deploy -Psign,deploy-central -DskipTests --no-transfer-progress
4155
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
57+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
4358
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
44-
- uses: actions/setup-java@v3
59+
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
60+
MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}
61+
62+
- uses: actions/setup-java@v4
4563
if: startsWith(github.ref, 'refs/tags/')
4664
with:
47-
java-version: 21
65+
java-version: ${{ env.JAVA_VERSION }}
4866
distribution: temurin
4967
cache: 'maven'
50-
server-id: ossrh
51-
server-username: MAVEN_USERNAME
52-
server-password: MAVEN_PASSWORD
53-
- name: Deploy to OSSRH
68+
69+
- name: Deploy to GitHub Packages
5470
if: startsWith(github.ref, 'refs/tags/')
55-
run: mvn -B deploy -Psign,deploy-central -DskipTests --no-transfer-progress
71+
run: mvn -B deploy -Psign,deploy-github -DskipTests --no-transfer-progress
5672
env:
57-
MAVEN_OPTS: >
58-
--add-opens=java.base/java.util=ALL-UNNAMED
59-
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
60-
--add-opens=java.base/java.text=ALL-UNNAMED
61-
--add-opens=java.desktop/java.awt.font=ALL-UNNAMED
62-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
63-
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6474
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
75+
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }}
76+
MAVEN_GPG_KEY_FINGERPRINT: ${{ vars.RELEASES_GPG_KEY_FINGERPRINT }}
77+
78+
- name: Attest
79+
if: startsWith(github.ref, 'refs/tags/')
80+
uses: actions/attest-build-provenance@v2
81+
with:
82+
subject-path: |
83+
target/tiny-oauth2-client-*.jar
84+
target/tiny-oauth2-client-*.pom
85+
6586
- name: Release
6687
if: startsWith(github.ref, 'refs/tags/')
67-
uses: softprops/action-gh-release@v1
88+
uses: softprops/action-gh-release@v2
6889
with:
6990
generate_release_notes: true

pom.xml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
<plugins>
138138
<plugin>
139139
<artifactId>maven-gpg-plugin</artifactId>
140-
<version>3.1.0</version>
140+
<version>3.2.7</version>
141141
<executions>
142142
<execution>
143143
<id>sign-artifacts</id>
@@ -146,10 +146,7 @@
146146
<goal>sign</goal>
147147
</goals>
148148
<configuration>
149-
<gpgArguments>
150-
<arg>--pinentry-mode</arg>
151-
<arg>loopback</arg>
152-
</gpgArguments>
149+
<signer>bc</signer>
153150
</configuration>
154151
</execution>
155152
</executions>
@@ -160,24 +157,16 @@
160157

161158
<profile>
162159
<id>deploy-central</id>
163-
<distributionManagement>
164-
<repository>
165-
<id>ossrh</id>
166-
<name>Maven Central</name>
167-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
168-
</repository>
169-
</distributionManagement>
170160
<build>
171161
<plugins>
172162
<plugin>
173-
<groupId>org.sonatype.plugins</groupId>
174-
<artifactId>nexus-staging-maven-plugin</artifactId>
175-
<version>1.6.13</version>
163+
<groupId>org.sonatype.central</groupId>
164+
<artifactId>central-publishing-maven-plugin</artifactId>
165+
<version>0.7.0</version>
176166
<extensions>true</extensions>
177167
<configuration>
178-
<serverId>ossrh</serverId>
179-
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
180-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
168+
<publishingServerId>central</publishingServerId>
169+
<autoPublish>true</autoPublish>
181170
</configuration>
182171
</plugin>
183172
</plugins>

0 commit comments

Comments
 (0)