Skip to content

Release v0.9.04 to Maven Central #22

Release v0.9.04 to Maven Central

Release v0.9.04 to Maven Central #22

Workflow file for this run

# This workflow releases the project on Maven Central
# and prepare a new development version
name: Release to Maven Central
run-name: Release v${{ inputs.releaseVersion }} to Maven Central
on:
#push:
# branches: [ main ]
workflow_dispatch:
inputs:
releaseVersion:
description: "Release version"
required: true
default: ""
developmentVersion:
description: "New SNAPSHOT version"
required: true
default: ""
autoRelease:
description: "Release staging repository immediately?"
required: true
type: boolean
default: false
permissions:
contents: write
pull-requests: write
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these releases and deployments to complete.
concurrency:
group: release
cancel-in-progress: false
# Default to bash
defaults:
run:
shell: bash
jobs:
release:
name: Release v${{ github.event.inputs.releaseVersion }}
runs-on: ubuntu-latest
outputs:
branchName: ${{ env.branchName }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK with Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
java-package: 'jdk'
cache: 'maven'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Configure Git User
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Set release branch and tag name
run: |
echo "branchName=release/v$INPUT_RELEASEVERSION" >> $GITHUB_ENV
echo "tagName=v$INPUT_RELEASEVERSION" >> $GITHUB_ENV
env:
INPUT_RELEASEVERSION: ${{ github.event.inputs.releaseVersion }}
- name: Create ${{ env.branchName }} branch
run: |
git checkout ${{ env.branchName }} 2>/dev/null || git checkout -b ${{ env.branchName }}
git push origin ${{ env.branchName }}
- name: Clean up existing ${{ env.tagName }} tags
run: |
git tag -d ${{ env.tagName }} || true
git push origin :refs/tags/${{ env.tagName }} || true
- name: Prepare release
id: prepare
run: |
mvn -B -U \
-Prelease \
release:clean \
release:prepare \
-DpreparationGoals="clean verify site" \
-Dgpg.passphraseServerId=gpg.passphrase \
-Darguments=-Dgpg.passphraseServerId=gpg.passphrase \
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} \
-Dresume=false
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
- name: Perform release to Maven Central
id: release
run: |
mvn -B -U \
-Prelease \
release:perform \
-Dgoals="deploy site" \
-DworkingDirectory=$GITHUB_WORKSPACE/target/release \
-Dgpg.passphraseServerId=gpg.passphrase \
-Darguments=-Dgpg.passphraseServerId=gpg.passphrase \
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \
-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} \
env:
AUTO_RELEASE_AFTER_CLOSE: ${{ github.event.inputs.autoRelease }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
- name: Release rollback on failure
run: |
mvn -B -U \
-Prelease \
release:rollback \
if: always() && (steps.prepare.outcome == 'failure' || steps.release.outcome == 'failure')
- name: Setup GitHub Pages
id: pages
uses: actions/configure-pages@v3
- name: Upload Maven Site to GitHub Pages
uses: actions/upload-pages-artifact@v2
with:
path: ./target/release/target/site
- name: Create a GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.tagName }}
fail_on_unmatched_files: false
generate_release_notes: true
files: |
./target/release/target/*.jar
./target/release/target/*.buildinfo
- name: Summary with staging repositories and buildinfo
id: stagingList
run: |
echo "# Staging Repositories" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
mvn -B -U \
-Prelease \
org.sonatype.plugins:nexus-staging-maven-plugin:rc-list >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "# Buildinfo" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cat target/*.buildinfo >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
# Pull Request from release branch to main
pull-request:
name: Create Pull Request
needs: release
runs-on: ubuntu-latest
steps:
- name: Create Pull Request from ${{ needs.release.outputs.branchName }} to ${{ github.event.repository.default_branch }}
run: |
gh pr create \
-B $BASE_BRANCH \
-H $HEAD_BRANCH \
--title "$PR_TITLE" \
--body "$PR_BODY"
env:
GITHUB_TOKEN: ${{ github.token }}
BASE_BRANCH: ${{ github.event.repository.default_branch }}
HEAD_BRANCH: ${{ needs.release.outputs.branchName }}
PR_TITLE: Release v${{ github.event.inputs.releaseVersion }} and prepare v${{ github.event.inputs.developmentVersion }}
PR_BODY: |
## Automated release
* Release **v${{ github.event.inputs.releaseVersion }}**
* Prepare **v${{ github.event.inputs.developmentVersion }}**
# Deployment job
deploy:
name: Deploy GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: release
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2