Skip to content

Commit 8c42039

Browse files
committed
Publish to maven-centrail
Publish new releases to maven-central and snapshots to github
1 parent 30996c3 commit 8c42039

File tree

4 files changed

+63
-14
lines changed

4 files changed

+63
-14
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will build a package using Maven and then publish it to Maven Central when a release is created
2+
# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-java-packages-with-maven
3+
4+
name: Maven Publish Release - Maven Central
5+
6+
on:
7+
release:
8+
types:
9+
- created
10+
11+
jobs:
12+
publish:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up JDK 21 - Maven Central
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '21'
22+
distribution: 'temurin'
23+
server-id: central # Value of the distributionManagement/repository/id field of the pom.xml
24+
server-username: MAVEN_USERNAME
25+
server-password: MAVEN_PASSWORD
26+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
gpg-passphrase: GPG_PASSPHRASE
28+
29+
- name: Build with Maven
30+
run: mvn -B package --file pom.xml
31+
32+
- name: Publish to Maven Central
33+
run: mvn -B deploy -Prelease
34+
env:
35+
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
36+
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
37+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.github/workflows/maven-publish-snapshot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
22
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
33

4-
name: Maven Publish Snapshot
4+
name: Maven Publish Snapshot - Github Packages
55

66
on:
77
push:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ buildNumber.properties
4141
.project
4242
# JDT-specific (Eclipse Java Development Tools)
4343
.classpath
44+
/.mvn/settings.xml
45+
/maven-central-private-key.asc

pom.xml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.sideshowcoder</groupId>
88
<artifactId>dropwizard-openfeature</artifactId>
9-
<version>0.0.2-SNAPSHOT</version>
9+
<version>0.0.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>dropwizard-openfeature</name>
@@ -30,10 +30,12 @@
3030
<maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
3131
<maven-failsafe-plugin.version>3.5.3</maven-failsafe-plugin.version>
3232
<mockito.version>5.17.0</mockito.version>
33+
<central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
3334
</properties>
3435

3536
<developers>
3637
<developer>
38+
<id>philipp.fehre</id>
3739
<name>Philipp Fehre</name>
3840
<url>https://github.com/sideshowcoder</url>
3941
</developer>
@@ -47,6 +49,11 @@
4749
</license>
4850
</licenses>
4951

52+
<issueManagement>
53+
<system>github</system>
54+
<url>https://github.com/sideshowcoder/dropwizard-openfeature/issues</url>
55+
</issueManagement>
56+
5057
<scm>
5158
<url>https://github.com/sideshowcoder/dropwizard-openfeature/tree/master</url>
5259
<connection>scm:git:[email protected]:sideshowcoder/dropwizard-openfeature.git</connection>
@@ -73,11 +80,11 @@
7380
</dependencyManagement>
7481

7582
<distributionManagement>
76-
<snapshotRepository>
77-
<id>github</id>
78-
<name>GitHub dropwizard-openfeature Apache Maven Packages</name>
79-
<url>https://maven.pkg.github.com/sideshowcoder/dropwizard-openfeature</url>
80-
</snapshotRepository>
83+
<repository>
84+
<id>central</id>
85+
<name>Maven Central</name>
86+
<url>https://central.sonatype.com</url>
87+
</repository>
8188
</distributionManagement>
8289

8390
<dependencies>
@@ -156,7 +163,6 @@
156163
<target>${java.version}</target>
157164
</configuration>
158165
</plugin>
159-
160166
<plugin>
161167
<groupId>org.jacoco</groupId>
162168
<artifactId>jacoco-maven-plugin</artifactId>
@@ -187,14 +193,18 @@
187193
<profile>
188194
<id>release</id>
189195

190-
<activation>
191-
<property>
192-
<name>release</name>
193-
</property>
194-
</activation>
195-
196196
<build>
197197
<plugins>
198+
<plugin>
199+
<groupId>org.sonatype.central</groupId>
200+
<artifactId>central-publishing-maven-plugin</artifactId>
201+
<version>${central-publishing-maven-plugin.version}</version>
202+
<extensions>true</extensions>
203+
<configuration>
204+
<publishingServerId>central</publishingServerId>
205+
<autoPublish>true</autoPublish>
206+
</configuration>
207+
</plugin>
198208
<plugin>
199209
<groupId>org.apache.maven.plugins</groupId>
200210
<artifactId>maven-source-plugin</artifactId>

0 commit comments

Comments
 (0)