Skip to content

Commit a90bc22

Browse files
authored
Create main.yml
1 parent ba47e4d commit a90bc22

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/main.yml

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+
3+
name: Maven Build & Deploy
4+
5+
on:
6+
push:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '11'
22+
distribution: 'temurin'
23+
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
24+
settings-path: ${{ github.workspace }} # location for the settings.xml file
25+
26+
- name: Build with Maven
27+
if: ${{ github.ref != 'refs/heads/master' }}
28+
run: mvn clean package --file pom.xml
29+
30+
- name: Set up Maven Central Repository
31+
uses: actions/setup-java@v3
32+
with:
33+
java-version: '11'
34+
distribution: 'adopt'
35+
server-id: ossrh
36+
server-username: MAVEN_USERNAME
37+
server-password: MAVEN_PASSWORD
38+
39+
- name: Import GPG key
40+
id: import_gpg
41+
uses: crazy-max/ghaction-import-gpg@v5
42+
with:
43+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
44+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
45+
46+
- name: Publish package
47+
if: contains(github.ref, 'release')
48+
run: mvn clean -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} --batch-mode deploy -DskipTests=true -P release
49+
env:
50+
MAVEN_USERNAME: ${{ secrets.MVN_USERNAME }}
51+
MAVEN_PASSWORD: ${{ secrets.MVN_PASSWORD }}

0 commit comments

Comments
 (0)