Skip to content

Commit 42dc753

Browse files
authored
Merge pull request #18 from cicirello/maven-workflow
Create maven-publish.yml
2 parents cb44621 + 90534b7 commit 42dc753

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Maven Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Get the release version
16+
id: get_version
17+
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT
18+
19+
- name: Set up JDK 17 for deploy to OSSRH
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'adopt'
23+
java-version: '17'
24+
server-id: ossrh
25+
server-username: MAVEN_USERNAME
26+
server-password: MAVEN_CENTRAL_TOKEN
27+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
28+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
29+
30+
- name: Build with Maven
31+
run: mvn -B package --file pom.xml
32+
33+
- name: Update package version
34+
run: mvn versions:set -DnewVersion=${{ steps.get_version.outputs.VERSION }}
35+
36+
- name: Publish to Apache Maven Central
37+
run: mvn deploy -PossrhDeploy
38+
env:
39+
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
40+
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
41+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
42+
43+
- name: Set up JDK 17 for deploy to github packages
44+
uses: actions/setup-java@v4
45+
with:
46+
distribution: 'adopt'
47+
java-version: '17'
48+
server-id: github
49+
50+
- name: Publish to GitHub Packages Apache Maven
51+
run: mvn deploy -PgithubDeploy
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)