Skip to content

Commit 5da8c1b

Browse files
authored
Adds GitHub Actions for publishing to Maven Central (#772)
* Adds GitHub Actions for publishing to Maven Central * Moves Central publishing plugin to profile * Adds missing empty last line * Adds another missing empty last line * readded license tool plugin and javadoc plugin to the MavenCentral profile
1 parent 376e3f6 commit 5da8c1b

File tree

3 files changed

+108
-42
lines changed

3 files changed

+108
-42
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish Release to Maven Central
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout source
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Java and Maven Central credentials
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: '17'
19+
distribution: 'temurin'
20+
server-id: central
21+
server-username: MAVEN_USERNAME
22+
server-password: MAVEN_PASSWORD
23+
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
24+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
25+
26+
- name: Set project version from tag
27+
run: mvn --batch-mode versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false
28+
29+
- name: Publish to Central
30+
run: mvn --batch-mode deploy -DskipTests -PperformRelease=true
31+
env:
32+
MAVEN_USERNAME: ${{ secrets.CENTRAL_SONATYPE_TOKEN_USERNAME }}
33+
MAVEN_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_TOKEN_PASSWORD }}
34+
MAVEN_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish Snapshot package to the Maven Central Repository
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '.github/ISSUE_TEMPLATE/**'
9+
- '.github/CODE_OF_CONDUCT.md'
10+
- '.github/CODING_CONVENTIONS.md'
11+
- '.github/CONTRIBUTING.md'
12+
- '.github/dependabot.yml'
13+
- '.github/pull_request_template.md'
14+
- '.github/SECURITY.md'
15+
- 'docs/**'
16+
- 'examples/**'
17+
- 'README.md'
18+
- '.gitattributes'
19+
- '.gitignore'
20+
- 'LICENSE'
21+
- 'NOTICE'
22+
23+
jobs:
24+
publish:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Set up Maven Central Repository
31+
uses: actions/setup-java@v4
32+
with:
33+
java-version: '17'
34+
distribution: 'temurin'
35+
server-id: central
36+
server-username: MAVEN_USERNAME
37+
server-password: MAVEN_PASSWORD
38+
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
39+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
40+
41+
- name: Publish package
42+
run: mvn --batch-mode deploy -DskipTests -PperformRelease=true
43+
env:
44+
MAVEN_USERNAME: ${{ secrets.CENTRAL_SONATYPE_TOKEN_USERNAME }}
45+
MAVEN_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_TOKEN_PASSWORD }}
46+
MAVEN_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}

pom.xml

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@
4747
</developers>
4848

4949

50-
<repositories>
51-
<repository>
52-
<id>central</id>
53-
<name>Maven Central</name>
54-
<layout>default</layout>
55-
<url>https://repo1.maven.org/maven2</url>
56-
<snapshots>
57-
<enabled>false</enabled>
58-
</snapshots>
59-
</repository>
60-
</repositories>
61-
6250
<scm>
6351
<connection>
6452
scm:git:https://github.com/eclipse-basyx/basyx-java-server-sdk.git</connection>
@@ -211,20 +199,6 @@
211199
</execution>
212200
</executions>
213201
</plugin>
214-
215-
<!-- Upload to Maven Central -->
216-
<plugin>
217-
<groupId>org.sonatype.plugins</groupId>
218-
<artifactId>nexus-staging-maven-plugin</artifactId>
219-
<version>1.7.0</version>
220-
<extensions>true</extensions>
221-
<configuration>
222-
<serverId>ossrh</serverId>
223-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
224-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
225-
<stagingProfileId>2d2ac71e07682f</stagingProfileId>
226-
</configuration>
227-
</plugin>
228202
<plugin>
229203
<groupId>io.fabric8</groupId>
230204
<artifactId>docker-maven-plugin</artifactId>
@@ -1404,29 +1378,41 @@
14041378
<profiles>
14051379
<profile>
14061380
<id>MavenCentral</id>
1407-
<distributionManagement>
1408-
<snapshotRepository>
1409-
<id>ossrh</id>
1410-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
1411-
</snapshotRepository>
1412-
<repository>
1413-
<id>ossrh</id>
1414-
<url>
1415-
https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
1416-
</repository>
1417-
</distributionManagement>
1381+
<activation>
1382+
<property>
1383+
<name>performRelease</name>
1384+
<value>true</value>
1385+
</property>
1386+
</activation>
14181387
<build>
14191388
<plugins>
1420-
<!-- Upload to maven central -->
1389+
<!-- Central Publishing Plugin -->
14211390
<plugin>
1422-
<groupId>org.sonatype.plugins</groupId>
1423-
<artifactId>nexus-staging-maven-plugin</artifactId>
1391+
<groupId>org.sonatype.central</groupId>
1392+
<artifactId>central-publishing-maven-plugin</artifactId>
1393+
<version>0.7.0</version>
1394+
<extensions>true</extensions>
1395+
<configuration>
1396+
<publishingServerId>central</publishingServerId>
1397+
<autoPublish>true</autoPublish>
1398+
<waitUntil>published</waitUntil>
1399+
<centralSnapshotsUrl>
1400+
https://central.sonatype.com/repository/maven-snapshots/</centralSnapshotsUrl>
1401+
</configuration>
14241402
</plugin>
1425-
1426-
<!-- Signing the artifacts -->
14271403
<plugin>
14281404
<groupId>org.apache.maven.plugins</groupId>
14291405
<artifactId>maven-gpg-plugin</artifactId>
1406+
<version>1.5</version>
1407+
<executions>
1408+
<execution>
1409+
<id>sign-artifacts</id>
1410+
<phase>verify</phase>
1411+
<goals>
1412+
<goal>sign</goal>
1413+
</goals>
1414+
</execution>
1415+
</executions>
14301416
</plugin>
14311417
<plugin>
14321418
<groupId>org.eclipse.dash</groupId>

0 commit comments

Comments
 (0)