Skip to content

Commit

Permalink
Publish to Maven Central when a tag is pushed
Browse files Browse the repository at this point in the history
  • Loading branch information
squarejesse committed Feb 24, 2024
1 parent b4ee2bb commit 857baad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name: Java CI with Maven
on:
push:
branches: [master]
tags: ["**"]
pull_request:
branches: [master]

Expand All @@ -26,6 +27,17 @@ jobs:
distribution: "adopt"
- name: Build with Maven
run: mvn test -B
- name: Import signing key
if: ${{ github.ref_type == 'tag' }}
env:
ARTIFACT_SIGNING_PRIVATE_KEY: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
run: echo "$ARTIFACT_SIGNING_PRIVATE_KEY" | gpg --import
- name: Release to Maven Central
if: ${{ github.ref_type == 'tag' }}
env:
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
run: mvn --activate-profiles release deploy --batch-mode --settings .maven_settings.xml

labeler:
needs: build
Expand Down
10 changes: 10 additions & 0 deletions .maven_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>ossrh</id>
<username>${env.SONATYPE_NEXUS_USERNAME}</username>
<password>${env.SONATYPE_NEXUS_PASSWORD}</password>
</server>
</servers>
</settings>

0 comments on commit 857baad

Please sign in to comment.