Skip to content

Commit b653491

Browse files
authored
automating releases to maven central (#8)
See #5 Co-authored-by: Rishabh Arora <rishabh.arora@clevertap.com>
1 parent b3ce2a8 commit b653491

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Set up JDK 1.8
14+
uses: actions/setup-java@v1
15+
with:
16+
java-version: 1.8
17+
18+
- name: Cache local Maven repository
19+
uses: actions/cache@v2
20+
with:
21+
path: ~/.m2/repository
22+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
23+
restore-keys: |
24+
${{ runner.os }}-maven-
25+
- id: install-secret-key
26+
name: Install GPG secret key
27+
run: |
28+
cat <(echo -e "${{ secrets.GPG_PRIVATE_KEY }}") | gpg --batch --import
29+
- name: Deploy
30+
run: |
31+
mvn -P gpg_verify \
32+
--no-transfer-progress \
33+
--batch-mode -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
34+
--file pom.xml -s release/m2-settings.xml verify deploy
35+
env:
36+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

pom.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
</dependency>
5454
</dependencies>
5555

56+
<distributionManagement>
57+
<snapshotRepository>
58+
<id>ossrh</id>
59+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
60+
</snapshotRepository>
61+
</distributionManagement>
62+
5663
<build>
5764
<plugins>
5865
<plugin>
@@ -76,6 +83,17 @@
7683
<artifactId>maven-surefire-plugin</artifactId>
7784
<version>2.22.1</version>
7885
</plugin>
86+
<plugin>
87+
<groupId>org.sonatype.plugins</groupId>
88+
<artifactId>nexus-staging-maven-plugin</artifactId>
89+
<version>1.6.7</version>
90+
<extensions>true</extensions>
91+
<configuration>
92+
<serverId>ossrh</serverId>
93+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
94+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
95+
</configuration>
96+
</plugin>
7997
</plugins>
8098
</build>
8199

@@ -136,4 +154,4 @@
136154
</license>
137155
</licenses>
138156

139-
</project>
157+
</project>

release/m2-settings.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<settings>
2+
<servers>
3+
<server>
4+
<id>ossrh</id>
5+
<username>${env.OSSRH_USERNAME}</username>
6+
<password>${env.OSSRH_PASSWORD}</password>
7+
</server>
8+
</servers>
9+
</settings>

0 commit comments

Comments
 (0)