Skip to content

Commit ba0278b

Browse files
authored
Merge pull request #36 from P2GX/setup-deploy-action
Setup deployment
2 parents b2cff39 + 1d334f5 commit ba0278b

File tree

5 files changed

+781
-4
lines changed

5 files changed

+781
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy to Sonatype Central
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger the workflow when a tag starting with 'v' is pushed, like v1.0.0
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v5
15+
16+
- name: Set up JDK 21
17+
uses: actions/setup-java@v5
18+
with:
19+
java-version: '21'
20+
distribution: 'adopt'
21+
22+
- name: Cache Maven dependencies
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.m2/repository
26+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
27+
restore-keys: |
28+
${{ runner.os }}-maven-
29+
30+
- name: Import GPG key
31+
run: |
32+
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --armor --batch --no-tty
33+
34+
- name: Setup Maven settings
35+
run: |
36+
rm ${HOME}/.m2/settings.xml
37+
38+
cat << EOF > ${HOME}/.m2/settings.xml
39+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
40+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
41+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
42+
<servers>
43+
<server>
44+
<id>central</id>
45+
<username>${{ secrets.SONATYPE_USERNAME }}</username>
46+
<password>${{ secrets.SONATYPE_PASSWORD }}</password>
47+
</server>
48+
</servers>
49+
</settings>
50+
EOF
51+
52+
- name: Deploy to Sonatype Central
53+
run: |
54+
./mvnw clean deploy --batch-mode -Prelease \
55+
-Dgpg.keyname=${{ secrets.GPG_KEY_ID }}

0 commit comments

Comments
 (0)