Publish to Maven Central #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to Maven Central | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version number for release' | |
required: true | |
jobs: | |
release: | |
name: Release to Maven Central | |
if: github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
env: | |
java-version: '8' | |
user: codeleep | |
email: [email protected] | |
gpg-keyname: ${{ secrets.MAVEN_GPG_KEY_NAME }} | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
server-username: ${{ secrets.CENTER_SERVER_USERNAME }} | |
server-password: ${{ secrets.CENTER_SERVER_PASSWORD }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Bump version | |
run: | | |
git pull | |
VERSION=${{ github.event.inputs.version }} | |
echo "INFO input tag: $VERSION" | |
mvn versions:set -DnewVersion=$VERSION -DgenerateBackupPoms=false | |
mvn versions:update-property -Dproperty=version.athena -DnewVersion=$VERSION -DgenerateBackupPoms=false | |
shell: bash | |
- name: Tag for release | |
run: | | |
git config --global user.name ${{ env.user }} | |
git config --global user.email ${{ env.email }} | |
git commit -am "Bump version to $VERSION" | |
echo "INFO Creating tag: ${{ github.event.inputs.version }}" | |
git tag ${{ github.event.inputs.version }} -a -m "Autogenerated version bump tag" | |
# Push the new tag | |
echo "INFO Pushing tag: ${{ github.event.inputs.version }}" | |
git push origin ${{ github.event.inputs.version }} | |
shell: bash | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
# https://stackoverflow.com/a/77710731/14312712 | |
java-version: ${{ env.java-version }} | |
distribution: 'adopt' | |
server-id: ${{ env.gpg-keyname }} | |
settings-path: ${{ github.workspace }} | |
gpg-private-key: ${{ env.gpg-private-key }} | |
gpg-passphrase: ${{ env.gpg-passphrase }} | |
server-username: ${{ env.server-username }} | |
server-password: ${{ env.server-password }} | |
- name: Prepare GPG | |
run: | | |
mkdir -p ~/.gnupg/ | |
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf | |
gpgconf --reload gpg-agent | |
shell: bash | |
- name: Configure settings.xml for Maven Central release | |
uses: whelk-io/maven-settings-xml-action@v20 | |
with: | |
servers: > | |
[ | |
{ | |
"id": "${{ env.gpg-keyname }}", | |
"username": "${{ env.server-username }}", | |
"password": "${{ env.server-password }}", | |
"passphrase": "${{ env.gpg-passphrase }}" | |
} | |
] | |
profiles: > | |
[ | |
{ | |
"id": "${{ env.gpg-keyname }}", | |
"properties": { | |
"gpg.keyname": "${{ env.gpg-keyname }}" | |
}, | |
"activation": { | |
"activeByDefault": "true" | |
} | |
} | |
] | |
- name: Release | |
run: mvn clean deploy -P release -DskipTests | |
shell: bash |