v1.2.1 #21
Workflow file for this run
This file contains 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: Release | |
on: | |
release: | |
types: [created] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Java for publishing to Maven Central Repository | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '8' | |
distribution: 'temurin' | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
- name: Install xmllint | |
run: | | |
sudo apt-get update -q | |
sudo apt-get install -y libxml2-utils | |
- name: Verify Version from pom.xml | |
run: | | |
# Extract the version from pom.xml using grep | |
POM_VERSION=$(xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" pom.xml) | |
# Get the release tag from the GitHub context | |
RELEASE_TAG=${{ github.ref }} | |
# Remove "refs/tags/" from the release tag | |
RELEASE_TAG=${RELEASE_TAG/refs\/tags\//} | |
# Remove the 'v' prefix fro the release tag, if present | |
RELEASE_TAG=${RELEASE_TAG#v} | |
if [ "$POM_VERSION" == "$RELEASE_TAG" ]; then | |
echo "Version in pom.xml matches the release tag: $RELEASE_TAG" | |
else | |
echo "Error: Version in pom.xml ($POM_VERSION) does not match the release tag ($RELEASE_TAG)" | |
exit 1 | |
fi | |
- id: install-secret-key | |
name: Import GPG Secret Key | |
run: | | |
# Install gpg secret key | |
cat <(echo -e "${{ secrets.GPG_KEY }}") | gpg --batch --import | |
# Verify gpg secret key | |
gpg --list-secret-keys --keyid-format LONG | |
- name: Publish to the Maven Central Repository | |
run: | | |
mvn \ | |
--batch-mode \ | |
-Dmaven.test.skip \ | |
-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \ | |
clean deploy | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} |