Skip to content

Commit 49f6968

Browse files
committed
[CI] Add deploy workflow for Maven Central releases
1 parent 3a48271 commit 49f6968

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Deploy to Maven Central
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- '[0-9]+.[0-9]+.[0-9]+*'
8+
workflow_dispatch:
9+
inputs:
10+
dry_run:
11+
description: 'Dry run (skip actual deploy)'
12+
required: false
13+
default: false
14+
type: boolean
15+
16+
jobs:
17+
deploy:
18+
name: Deploy to Maven Central
19+
runs-on: [self-hosted, Linux, x64]
20+
timeout-minutes: 15
21+
env:
22+
JAVA_HOME: /opt/jenkins/jdks/graal-23.1.0/jdk-21.0.3
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup environment
29+
run: |
30+
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
31+
32+
- name: Configure Maven settings
33+
run: |
34+
mkdir -p ~/.m2
35+
cat > ~/.m2/settings.xml << 'EOF'
36+
<settings>
37+
<servers>
38+
<server>
39+
<id>central</id>
40+
<username>${env.MAVEN_USERNAME}</username>
41+
<password>${env.MAVEN_PASSWORD}</password>
42+
</server>
43+
</servers>
44+
<profiles>
45+
<profile>
46+
<id>gpg</id>
47+
<properties>
48+
<gpg.executable>gpg</gpg.executable>
49+
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
50+
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
51+
</properties>
52+
</profile>
53+
</profiles>
54+
<activeProfiles>
55+
<activeProfile>gpg</activeProfile>
56+
</activeProfiles>
57+
</settings>
58+
EOF
59+
60+
- name: Import GPG key
61+
run: |
62+
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
63+
env:
64+
GPG_TTY: $(tty)
65+
66+
- name: Deploy to Maven Central
67+
if: ${{ !inputs.dry_run }}
68+
run: |
69+
./mvnw clean deploy \
70+
-P release \
71+
-DskipTests \
72+
--batch-mode
73+
env:
74+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
75+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
76+
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
77+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
78+
79+
- name: Dry Run - Verify build only
80+
if: ${{ inputs.dry_run }}
81+
run: |
82+
./mvnw clean verify \
83+
-P release \
84+
-DskipTests \
85+
--batch-mode
86+
env:
87+
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
88+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

0 commit comments

Comments
 (0)