Skip to content

Commit 0b7bb20

Browse files
committed
Adds Maven Central Repository deploy workflow in CI/CD
1 parent a97b954 commit 0b7bb20

3 files changed

Lines changed: 77 additions & 34 deletions

File tree

.github/workflows/publish-github-package.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish package to GitHub Packages
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up GitHub Packages
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '8'
22+
distribution: 'temurin'
23+
24+
- name: Build with Maven
25+
run: mvn -B package --file pom.xml
26+
27+
- name: Publish to GitHub Packages Apache Maven
28+
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
29+
env:
30+
GITHUB_TOKEN: ${{ github.token }}
31+
32+
- name: Set up Apache Maven Central
33+
uses: actions/setup-java@v4
34+
with:
35+
java-version: '8'
36+
distribution: 'temurin'
37+
server-id: ossrh
38+
server-username: MAVEN_CENTRAL_USERNAME
39+
server-password: MAVEN_CENTRAL_PASSWORD
40+
gpg-private-key: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }}
41+
gpg-passphrase: MAVEN_CENTRAL_GPG_SECRET_KEY_PASSWORD
42+
43+
- name: Publish to Apache Maven Central
44+
run: mvn deploy
45+
env:
46+
MAVEN_CENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
47+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
48+
MAVEN_CENTRAL_GPG_SECRET_KEY_PASSWORD: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY_PASSWORD }}

pom.xml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
<description>SMSAPI client library</description>
1010

1111
<distributionManagement>
12+
<snapshotRepository>
13+
<id>ossrh</id>
14+
<name>Central Snapshot Repository OSSRH</name>
15+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
16+
</snapshotRepository>
1217
<repository>
13-
<id>github</id>
14-
<name>GitHub Packages</name>
15-
<url>https://maven.pkg.github.com/smsapi/smsapi-java-client</url>
18+
<id>ossrh</id>
19+
<name>Central Repository OSSRH</name>
20+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
1621
</repository>
1722
</distributionManagement>
1823

@@ -118,6 +123,27 @@
118123
</configuration>
119124
</plugin>
120125

126+
<plugin>
127+
<groupId>org.apache.maven.plugins</groupId>
128+
<artifactId>maven-gpg-plugin</artifactId>
129+
<version>3.2.5</version>
130+
<executions>
131+
<execution>
132+
<id>sign-artifacts</id>
133+
<phase>verify</phase>
134+
<goals>
135+
<goal>sign</goal>
136+
</goals>
137+
</execution>
138+
</executions>
139+
<configuration>
140+
<gpgArguments>
141+
<arg>--pinentry-mode</arg>
142+
<arg>loopback</arg>
143+
</gpgArguments>
144+
</configuration>
145+
</plugin>
146+
121147
</plugins>
122148
</build>
123149
</project>

0 commit comments

Comments
 (0)