Skip to content

Deploy to Sonatype by @trydofor #3

Deploy to Sonatype by @trydofor

Deploy to Sonatype by @trydofor #3

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:
inputs:
testCoverReport:
description: 'test and coveralls report?'
default: true
type: boolean
required: false
testFailureIgnore:
description: 'test ignore failure?'
default: false
type: boolean
required: false
testLoggerLevel:
description: 'test logger level'
default: WARN
type: choice
options:
- DEBUG
- INFO
- WARN
- ERROR
required: false
release:
types: [published]
jobs:
release:
name: Release to Sonatype
runs-on: ubuntu-latest
env:
MAVEN_OPTS: -Xmx2g
LOG_LEVEL: ${{ inputs.testLoggerLevel }}
WINGS_HOME: ${{ github.workspace }}
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 --quiet --non-recursive -DforceStdout -Dexpression=project.version ${{ steps.opt-revision.outputs.OPT_REVISION }} help:evaluate
echo
mvn -v
git --no-pager log --graph -10 --pretty=format:'%H - %an, %ad %d : %s'
env:
JAVA_HOME: ${{ steps.java-env.outputs.JAVA_HOME }}
## ci report if not release
- name: Coveralls Report
if: inputs.testCoverReport
run: >
mvn
-P ci
--quiet
-Duser.timezone=Asia/Shanghai
-Dtesting-json='{
"debug":"${{ inputs.testLoggerLevel == 'DEBUG' }}",
"test-verbose":"${{ inputs.testLoggerLevel == 'DEBUG' }}",
"sentry.logging.enabled":"${{ inputs.testLoggerLevel == 'DEBUG' }}",
"spring.wings.silencer.enabled.verbose":"${{ inputs.testLoggerLevel == 'DEBUG' }}",
"logging.level.root":"${{ inputs.testLoggerLevel }}",
"logging.level.org.springframework.web":"${{ inputs.testLoggerLevel }}",
"logging.level.org.jooq":"${{ inputs.testLoggerLevel }}"
}'
-Dmaven.test.failure.ignore=${{ inputs.testFailureIgnore }}
-DrepoToken=${{ secrets.COVERALLS_REPO_TOKEN }}
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,-example
${{ steps.opt-revision.outputs.OPT_REVISION }}
-Dgpg.passphrase=${MVN_GPG_PASS}
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 }}