Deploy to Maven Central #103
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
# This workflow will build a Java project with Maven and deploy snapshot | |
# artifacts to Maven Central | |
# | |
# This job is triggered by a completed run of the "CI Build" action. | |
# The "build" job only runs if the "CI Build" action completed successfully. | |
# The deployed artifacts will be built from the same commit that the "CI Build" action used. | |
# | |
name: Deploy to Maven Central | |
on: | |
workflow_run: | |
workflows: ["CI Build"] | |
branches: [ main, develop-6.x ] | |
types: | |
- completed | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
GIT_USER: ${{ secrets.BOT_USERNAME }} | |
GIT_EMAIL: ${{ secrets.BOT_EMAIL }} | |
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false | |
jobs: | |
build: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
- name: Cache Maven packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Build with Maven | |
env: | |
MAVEN_SONATYPE_USERNAME: ${{ secrets.MAVEN_SONATYPE_USERNAME }} | |
MAVEN_SONATYPE_TOKEN: ${{ secrets.MAVEN_SONATYPE_TOKEN }} | |
GIT_COMMIT: ${{github.event.workflow_run.head_commit.id}} | |
HEAD_BRANCH: ${{github.event.workflow_run.head_branch}} | |
run: | | |
echo "Checking out branch ${HEAD_BRANCH} commit ${GIT_COMMIT}" | |
git checkout "${GIT_COMMIT}" | |
git config --local user.name "${GIT_USER}" | |
git config --local user.email "${GIT_EMAIL}" | |
sh etc/deploy-snapshots.sh |