Skip to content

Manual GitHub Release Trigger #6

Manual GitHub Release Trigger

Manual GitHub Release Trigger #6

name: Manual GitHub Release Trigger
on:
workflow_dispatch:
env:
MAVEN_OPTS: ${{ vars.MAVEN_OPTS }}
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Prepare Maven settings.xml
run: |
cat "${{ github.workspace }}/.github/settings.xml" > ~/.m2/settings.xml
- name: Get Maven Project Version
run: |
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Manual Release Approval
uses: trstringer/[email protected]
timeout-minutes: 60
with:
secret: ${{ github.TOKEN }}
approvers: oranheim
issue-title: "Approve release of ${{ env.RELEASE_VERSION }}"
- name: Configure Git User
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Import and Verify GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.OSSRH_GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
GPG_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
echo "Verifying GPG passphrase..."
echo "test" | gpg --batch --yes --passphrase "$GPG_PASSPHRASE" --local-user "$GPG_KEY_ID" --armor --detach-sign --pinentry-mode loopback
- name: Release with Maven
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
GPG_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}
run: |
mvn -X --batch-mode release:clean release:prepare release:perform \
-Darguments="-Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEY_ID} -DskipTests" \
-DskipTests \
-P oss-maven-central
- name: Notify on success
if: success()
run: |
echo "Release ${{ env.RELEASE_VERSION }} has been successfully deployed to Maven Central."
- name: Notify on failure
if: failure()
run: |
echo "Release ${{ env.RELEASE_VERSION }} failed. Please check the logs for more information."