Skip to content

Commit 95f7b45

Browse files
authored
[chore] Set up Actions-based release process (#326)
1 parent 69b59ae commit 95f7b45

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.github/workflows/publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This workflow will build a Java project with Maven and publish it to Maven Central Repository
2+
# ref: https://github.com/actions/setup-java/blob/v3.11.0/docs/advanced-usage.md#Publishing-using-Apache-Maven
3+
4+
# Secrets required:
5+
# - MAVEN_USERNAME: Username for Maven Central Repository
6+
# - MAVEN_CENTRAL_TOKEN: Token/password for Maven Central Repository
7+
# - MAVEN_GPG_PRIVATE_KEY: GPG private key to sign the artifacts (string)
8+
# - MAVEN_GPG_PASSPHRASE: Passphrase for the GPG private key
9+
10+
name: Publish library to Maven Central Repository
11+
12+
on:
13+
release:
14+
types: [ created ]
15+
secrets:
16+
MAVEN_USERNAME:
17+
required: true
18+
MAVEN_CENTRAL_TOKEN:
19+
required: true
20+
MAVEN_GPG_PRIVATE_KEY:
21+
required: true
22+
MAVEN_GPG_PASSPHRASE:
23+
required: true
24+
workflow_dispatch: ~
25+
26+
jobs:
27+
release:
28+
runs-on: ubuntu-20.04
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Install JDK
36+
uses: actions/setup-java@v3
37+
with:
38+
distribution: "zulu"
39+
java-version: "22" # Always use the latest JDK
40+
server-id: "ossrh"
41+
# define environmental variable names
42+
server-username: MAVEN_USERNAME
43+
server-password: MAVEN_CENTRAL_TOKEN
44+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
45+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
46+
47+
- name: Clean, build and publish to Apache Maven Central
48+
run: make publish pass=${{ secrets.MAVEN_GPG_PASSPHRASE }}
49+
env:
50+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
51+
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
52+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
53+
54+
- name: Upload output files to release
55+
uses: AButler/[email protected]
56+
with:
57+
files: "target/*.jar;target/*.pom;target/*.asc"
58+
repo-token: ${{ secrets.GITHUB_TOKEN }}

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@
205205
<groupId>org.apache.maven.plugins</groupId>
206206
<artifactId>maven-gpg-plugin</artifactId>
207207
<version>3.1.0</version>
208+
<configuration>
209+
<!-- Needed to read passphrase from settings.xml -->
210+
<gpgArguments>
211+
<arg>--pinentry-mode</arg>
212+
<arg>loopback</arg>
213+
</gpgArguments>
214+
</configuration>
208215
<executions>
209216
<execution>
210217
<id>sign-artifacts</id>

0 commit comments

Comments
 (0)