Skip to content

Deploy 1.5.0 to Sonatype by @trydofor #4

Deploy 1.5.0 to Sonatype by @trydofor

Deploy 1.5.0 to Sonatype by @trydofor #4

Workflow file for this run

name: Release-To-OssRh
run-name: Deploy ${{github.event.release.tag_name}} to Sonatype by @${{ github.actor }}
on:
workflow_dispatch:
release:
types: [published]
jobs:
release:
name: Release to Sonatype
runs-on: ubuntu-latest
steps:
- name: Checkout ${{github.event.release.tag_name}}
uses: actions/checkout@v4
## chache asdf/, m2/repository
- name: Cache Sdk & Repo
id: cache-sdk-repo
uses: actions/cache@v3
with:
path: |
~/.asdf/
~/.m2/repository/
key: asdf-m2-repo-${{hashFiles('.tool-versions')}}
## install jdk and maven
- name: Install asdf & tools
uses: asdf-vm/actions/install@v2
with:
skip_install: ${{steps.cache-sdk-repo.outputs.cache-hit == 'true'}}
## write settings.xml
- name: Maven settings.xml
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << "EOF"
<settings>
<interactiveMode>false</interactiveMode>
<servers>
<server>
<id>ossrh</id>
<username>${MVN_OSS_USER}</username>
<password>${MVN_OSS_PASS}</password>
</server>
</servers>
</settings>
EOF
## get JAVA_HOME
- name: Env JAVA_HOME
id: java-env
run: echo "JAVA_HOME=$(asdf where java)" >> "$GITHUB_OUTPUT"
## get revision if release
- name: Opt revision
id: opt-revision
if: github.event.release.tag_name != ''
run: echo "OPT_REVISION=-Drevision=${{github.event.release.tag_name}}" >> "$GITHUB_OUTPUT"
## info deploy
- name: Info Deploy
run: |
mvn -v ${{ steps.opt-revision.outputs.OPT_REVISION }}
git log --pretty=format:'%H - %an, %ad %d : %s' --graph -10
env:
JAVA_HOME: ${{ steps.java-env.outputs.JAVA_HOME }}
## ci report if not release
- name: Coveralls Report
if: github.event.release.tag_name == ''
run: >
mvn -P ci --quiet
-DrepoToken=${{ secrets.COVERALLS_REPO_TOKEN }}
-Dmeepo.log-level=ERROR
clean test jacoco:report coveralls:report
env:
JAVA_HOME: ${{ steps.java-env.outputs.JAVA_HOME }}
## import gpp private key
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.MVN_GPG_SKEY }}
passphrase: ${{ secrets.MVN_GPG_PASS }}
## maven deploy
- name: Maven Deploy
run: >
mvn
-P ossrh
${{ steps.opt-revision.outputs.OPT_REVISION }}
-Dgpg.passphrase=${MVN_GPG_PASS}
-Dmaven.test.skip=true
clean deploy
env:
JAVA_HOME: ${{ steps.java-env.outputs.JAVA_HOME }}
MVN_OSS_USER: ${{ secrets.MVN_OSS_USER }}
MVN_OSS_PASS: ${{ secrets.MVN_OSS_PASS }}
MVN_GPG_PASS: ${{ secrets.MVN_GPG_PASS }}