Skip to content

Commit 6c6504f

Browse files
authored
Create release_and_push.yml
1 parent 1317fb4 commit 6c6504f

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2+
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
3+
4+
name: release and push to maven central repo
5+
6+
on:
7+
push:
8+
tags:
9+
- '*'
10+
workflow_dispatch:
11+
# release:
12+
# types: [created]
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Set up Java for publishing to Maven Central Repository
25+
uses: actions/setup-java@v3
26+
with:
27+
java-version: '17'
28+
server-id: ossrh
29+
server-username: MAVEN_USERNAME
30+
server-password: MAVEN_PASSWORD
31+
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
32+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
33+
34+
- name: build artifact
35+
run: mvn clean package
36+
37+
- name: Create Release
38+
uses: ncipollo/release-action@v1.12.0
39+
with:
40+
allowUpdates: true
41+
artifacts: "${{ github.workspace }}/target/*.jar"
42+
token: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Publish to the Maven Central Repository
45+
run: mvn --no-transfer-progress \
46+
--batch-mode \
47+
deploy
48+
env:
49+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
50+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
51+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SECRET_KEY_PASSWORD }}

0 commit comments

Comments
 (0)