Skip to content

Commit 2fcceb2

Browse files
committed
migrate from OSSRH to maven central publishing
1 parent 69553d9 commit 2fcceb2

File tree

3 files changed

+19
-42
lines changed

3 files changed

+19
-42
lines changed

.github/workflows/publish-central.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
name: Publish to Maven Central
22
on:
3-
workflow_dispatch:
4-
inputs:
5-
tag:
6-
description: 'Tag'
7-
required: true
8-
default: '0.0.0'
3+
release:
4+
types: [published]
95
jobs:
106
publish:
117
runs-on: ubuntu-latest
8+
if: startsWith(github.ref, 'refs/tags/') # only allow publishing tagged versions
129
steps:
1310
- uses: actions/checkout@v4
14-
with:
15-
ref: "refs/tags/${{ github.event.inputs.tag }}"
1611
- uses: actions/setup-java@v4
1712
with:
1813
distribution: 'temurin'
1914
java-version: 17
2015
cache: 'maven'
21-
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
22-
server-username: MAVEN_USERNAME # env variable for username in deploy
23-
server-password: MAVEN_PASSWORD # env variable for token in deploy
24-
- name: Enforce project version ${{ github.event.inputs.tag }}
25-
run: mvn versions:set -B -DnewVersion=${{ github.event.inputs.tag }}
16+
server-id: central
17+
server-username: MAVEN_CENTRAL_USERNAME
18+
server-password: MAVEN_CENTRAL_PASSWORD
19+
- name: Verify project version = ${{ github.event.release.tag_name }}
20+
run: |
21+
PROJECT_VERSION=$(mvn help:evaluate "-Dexpression=project.version" -q -DforceStdout)
22+
test "$PROJECT_VERSION" = "${{ github.event.release.tag_name }}"
2623
- name: Deploy
2724
run: mvn deploy -B -DskipTests -Psign,deploy-central --no-transfer-progress
2825
env:
@@ -31,7 +28,7 @@ jobs:
3128
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
3229
--add-opens=java.base/java.text=ALL-UNNAMED
3330
--add-opens=java.desktop/java.awt.font=ALL-UNNAMED
34-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
35-
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
31+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
32+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
3633
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
3734
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import

.github/workflows/publish-github.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,4 @@ jobs:
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2222
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASES_GPG_PASSPHRASE }}
23-
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
24-
- name: Slack Notification
25-
uses: rtCamp/action-slack-notify@v2
26-
env:
27-
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
28-
SLACK_USERNAME: 'Cryptobot'
29-
SLACK_ICON:
30-
SLACK_ICON_EMOJI: ':bot:'
31-
SLACK_CHANNEL: 'cryptomator-desktop'
32-
SLACK_TITLE: "Published ${{ github.event.repository.name }} ${{ github.event.release.tag_name }}"
33-
SLACK_MESSAGE: "Ready to <https://github.com/${{ github.repository }}/actions/workflows/publish-central.yml|deploy to Maven Central>."
34-
SLACK_FOOTER:
35-
MSG_MINIMAL: true
23+
MAVEN_GPG_KEY: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import

pom.xml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<mvn-surefire.version>3.5.2</mvn-surefire.version>
4343
<mvn-javadoc.version>3.11.2</mvn-javadoc.version>
4444
<mvn-gpg.version>3.2.7</mvn-gpg.version>
45-
<nexus-staging.version>1.7.0</nexus-staging.version>
45+
<central-publishing.version>0.7.0</central-publishing.version>
4646
</properties>
4747

4848
<licenses>
@@ -198,24 +198,16 @@
198198

199199
<profile>
200200
<id>deploy-central</id>
201-
<distributionManagement>
202-
<repository>
203-
<id>ossrh</id>
204-
<name>Maven Central</name>
205-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
206-
</repository>
207-
</distributionManagement>
208201
<build>
209202
<plugins>
210203
<plugin>
211-
<groupId>org.sonatype.plugins</groupId>
212-
<artifactId>nexus-staging-maven-plugin</artifactId>
213-
<version>${nexus-staging.version}</version>
204+
<groupId>org.sonatype.central</groupId>
205+
<artifactId>central-publishing-maven-plugin</artifactId>
206+
<version>${central-publishing.version}</version>
214207
<extensions>true</extensions>
215208
<configuration>
216-
<serverId>ossrh</serverId>
217-
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
218-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
209+
<publishingServerId>central</publishingServerId>
210+
<autoPublish>true</autoPublish>
219211
</configuration>
220212
</plugin>
221213
</plugins>

0 commit comments

Comments
 (0)