Skip to content

Commit 99e4f84

Browse files
committed
Refactor GitHub Actions workflow for Maven publishing by removing redundant setup for Maven Central Repository and updating settings.xml creation to include proper server configurations. This enhances clarity and streamlines the deployment process.
1 parent 22ddcbd commit 99e4f84

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

.github/workflows/maven-publish.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ jobs:
2020
distribution: 'temurin'
2121
cache: maven
2222

23-
- name: Set up Maven Central Repository
24-
uses: actions/setup-java@v3
25-
with:
26-
java-version: '17'
27-
distribution: 'temurin'
28-
server-id: central
29-
server-username: MAVEN_USERNAME
30-
server-password: MAVEN_PASSWORD
31-
3223
- name: Import GPG key
3324
run: |
3425
echo "${{ secrets.GPG_PRIVATE_KEY }}" > private.asc
@@ -41,16 +32,23 @@ jobs:
4132
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
4233
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
4334
run: |
44-
# Create settings.xml with GPG passphrase config
35+
# Create settings.xml with proper server configurations
4536
mkdir -p ~/.m2
46-
echo '<settings>
37+
cat > ~/.m2/settings.xml << EOF
38+
<settings>
4739
<servers>
40+
<server>
41+
<id>central</id>
42+
<username>\${env.MAVEN_USERNAME}</username>
43+
<password>\${env.MAVEN_PASSWORD}</password>
44+
</server>
4845
<server>
4946
<id>gpg.passphrase</id>
50-
<passphrase>${env.GPG_PASSPHRASE}</passphrase>
47+
<passphrase>\${env.GPG_PASSPHRASE}</passphrase>
5148
</server>
5249
</servers>
53-
</settings>' > ~/.m2/settings.xml
50+
</settings>
51+
EOF
5452
5553
# Build and deploy
5654
mvn -B clean deploy

0 commit comments

Comments
 (0)