Skip to content

Commit 3e2c3e9

Browse files
committed
feat: add github workflow for publishing to maven central
1 parent 9a0e30e commit 3e2c3e9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# .github/workflows/publish-to-maven.yml
2+
name: Publish to Maven Central
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Version to publish (e.g., 3.0.0)'
9+
required: true
10+
type: string
11+
12+
permissions:
13+
actions: read
14+
contents: read
15+
id-token: write
16+
17+
jobs:
18+
publish:
19+
if: github.event.sender.site_admin == true
20+
runs-on: [self-hosted, linux]
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up JDK
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: 'temurin'
29+
java-version: '21'
30+
31+
- name: Prepare root gradle.properties
32+
run: |
33+
echo "mavenCentralUsername=${{ secrets.MAVEN_CENTRAL_USERNAME }}" >> gradle.properties
34+
echo "mavenCentralPassword=${{ secrets.MAVEN_CENTRAL_PASSWORD }}" >> gradle.properties
35+
echo "signing.password=${{ secrets.SIGNING_PASSWORD }}" >> gradle.properties
36+
echo "signing.keyId=${{ secrets.SIGNING_KEY_ID }}" >> gradle.properties
37+
echo "signing.secretKeyRingFile=secring.gpg" >> gradle.properties
38+
39+
# Write secret keyring file
40+
echo "${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}" | base64 -d > secring.gpg
41+
42+
- name: Set VERSION_NAME in library/gradle.properties
43+
run: |
44+
if grep -q "^VERSION_NAME=" library/gradle.properties; then
45+
sed -i "s/^VERSION_NAME=.*/VERSION_NAME=${{ github.event.inputs.version }}/" library/gradle.properties
46+
else
47+
echo "VERSION_NAME=${{ github.event.inputs.version }}" >> library/gradle.properties
48+
fi
49+
- name: Run publish and release
50+
run: ./gradlew :library:publishAndReleaseToMavenCentral --no-configuration-cache

0 commit comments

Comments
 (0)