Skip to content

Manual GitHub Release Trigger #2

Manual GitHub Release Trigger

Manual GitHub Release Trigger #2

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 GPG key
run: |
echo "${{ secrets.OSSRH_GPG_PRIVATE_KEY }}" | gpg --batch --import
- name: Release with Maven
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
run: |
mvn --batch-mode release:clean release:prepare release:perform \
-Darguments="-DskipTests -Dgpg.passphrase=${GPG_PASSPHRASE}" \
-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."