Skip to content

Release main by @push #114

Release main by @push

Release main by @push #114

Workflow file for this run

name: Release to Maven Repo
run-name: Release ${{ github.ref_name }} by @${{ github.event_name }}
on:
workflow_dispatch:
inputs:
testCoverReport:
description: 'test and coverage report?'
default: true
type: boolean
required: false
testFailureIgnore:
description: 'test ignore failure?'
default: false
type: boolean
required: false
testCoverageDryRun:
description: 'dryrun coverage report?'
default: false
type: boolean
required: false
testLoggerLevel:
description: 'test logger level'
default: INFO
type: choice
options:
- DEBUG
- INFO
- WARN
- ERROR
applyQodanaScan:
description: 'apply Qodana Scan?'
default: true
type: boolean
required: false
deployOssrh:
description: 'deploy to oss-repo?'
default: true
type: boolean
required: false
deployAltrh:
description: 'deploy to alt-repo?'
default: true
type: boolean
required: false
release:
types: [published]
push:
branches:
- 'main'
jobs:
release:
name: Release to Sonatype
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
env:
MAVEN_OPTS: -Xmx2g
LOG_LEVEL: ${{ inputs.testLoggerLevel || 'INFO' }}
TEST_VERBOSE: ${{ inputs.testLoggerLevel == 'DEBUG' }}
steps:
- name: Checkout ${{ github.event.release.tag_name }}
uses: actions/checkout@v4
with:
fetch-depth: 10
## chache asdf/, m2/repository
- name: Cache Sdk & Repo
id: cache-sdk-repo
uses: actions/cache@v4
with:
path: |
~/.asdf/
~/.m2/repository/
key: asdf-m2-repo-${{ hashFiles('pom.xml') }}
## install jdk and maven
- name: Install asdf & tools
uses: asdf-vm/actions/install@v3
with:
skip_install: ${{ steps.cache-sdk-repo.outputs.cache-hit == 'true' }}
## write settings.xml
- name: Maven settings.xml
id: settings
run: |
echo "# env and var" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
JAVA_HOME=$(asdf where java)
echo "- JAVA_HOME=$JAVA_HOME" >> "$GITHUB_STEP_SUMMARY"
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_OUTPUT"
echo "- GIT_BRANCH=$(git branch --show-current)" >> "$GITHUB_STEP_SUMMARY"
echo "GIT_BRANCH=$(git branch --show-current)" >> "$GITHUB_OUTPUT"
_opt=$(git describe --tags --exact-match 2>/dev/null || true)
if [ "$_opt" != "" ]; then
_opt="-Drevision=$_opt"
echo "- MVN_REVISION=$_opt" >> "$GITHUB_STEP_SUMMARY"
echo "MVN_REVISION=$_opt" >> "$GITHUB_OUTPUT"
fi
_ver=$(mvn --quiet --non-recursive -DforceStdout -Dexpression=project.version $_opt help:evaluate)
echo "- WINGS_VERSION=$_ver" >> "$GITHUB_STEP_SUMMARY"
echo "WINGS_VERSION=$_ver" >> "$GITHUB_OUTPUT"
_cov=${{ inputs.testCoverReport || github.event_name == 'push' }}
echo "- MVN_COVERAGE=$_cov" >> "$GITHUB_STEP_SUMMARY"
echo "MVN_COVERAGE=$_cov" >> "$GITHUB_OUTPUT"
_drh=${{ inputs.deployOssrh || github.event_name == 'release' }}
echo "- MVN_DEPLOY_OSSRH=$_drh" >> "$GITHUB_STEP_SUMMARY"
echo "MVN_DEPLOY_OSSRH=$_drh" >> "$GITHUB_OUTPUT"
_drp=${{ secrets.MVN_ALT_USER != '' && ( inputs.deployAltrh || github.event_name == 'push' ) }}
echo "- MVN_DEPLOY_ALTRH=$_drp" >> "$GITHUB_STEP_SUMMARY"
echo "MVN_DEPLOY_ALTRH=$_drp" >> "$GITHUB_OUTPUT"
_qod=${{ inputs.applyQodanaScan || 'false' }}
echo "- QODANA_SCAN=$_qod" >> "$GITHUB_STEP_SUMMARY"
echo "QODANA_SCAN=$_qod" >> "$GITHUB_OUTPUT"
echo "# mvn and git" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```text' >> "$GITHUB_STEP_SUMMARY"
mvn -v >> "$GITHUB_STEP_SUMMARY"
git --no-pager log --graph -10 --pretty=format:'%H - %ai %d %s' >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
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>
<server>
<id>altrh</id>
<username>${MVN_ALT_USER}</username>
<password>${MVN_ALT_PASS}</password>
</server>
</servers>
</settings>
EOF
- name: Qodana Scan
uses: JetBrains/qodana-action@v2023.3
if: steps.settings.outputs.QODANA_SCAN == 'true'
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
## report if not release
- name: Test Coverage ${{ steps.settings.outputs.WINGS_VERSION }} ${{ steps.settings.outputs.GIT_BRANCH }}
if: steps.settings.outputs.MVN_COVERAGE == 'true'
run: |
mvn -P '!module-example,!module-devs' -Dmaven.test.skip=true clean install
mvn -pl ':devs-codegen' -Ddevs-initdb=true clean test
mvn -P 'report-coverage,!module-example,!module-devs' -Dmaven.test.failure.ignore=$TESTFAILS_IGNORE test
mvn -P 'report-coverage' -pl ':devs-coverage' -am jacoco:report-aggregate
mvn -pl ':devs-coverage' -DrepoToken=$COVERALLS_WINGS -DdryRun=$COVERALLS_DRYRUN -Dwings.rootdir=../.. coveralls:report
env:
TZ: Asia/Shanghai
JAVA_HOME: ${{ steps.settings.outputs.JAVA_HOME }}
COVERALLS_WINGS: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_DRYRUN: ${{ inputs.testCoverageDryRun || 'false' }}
TESTFAILS_IGNORE: ${{ inputs.testFailureIgnore || 'false' }}
## import gpp private key
- name: Import GPG key
if: steps.settings.outputs.MVN_DEPLOY_OSSRH == 'true' || steps.settings.outputs.MVN_DEPLOY_ALTRH == 'true'
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.MVN_GPG_SKEY }}
passphrase: ${{ secrets.MVN_GPG_PASS }}
## maven deploy ossrh
- name: Deploy OSS ${{ steps.settings.outputs.WINGS_VERSION }} ${{ steps.settings.outputs.GIT_BRANCH }}
if: steps.settings.outputs.MVN_DEPLOY_OSSRH == 'true'
run: >
mvn
-P 'deploy,deploy-oss,!module-example,!module-devs'
${{ steps.settings.outputs.MVN_REVISION }}
-Dgpg.passphrase=${MVN_GPG_PASS}
-Dorg.slf4j.simpleLogger.log.lombok=WARN
-Dorg.slf4j.simpleLogger.log.org.jetbrains.dokka=WARN
-Dorg.slf4j.simpleLogger.log.pl.project13.maven.git=WARN
deploy
env:
JAVA_HOME: ${{ steps.settings.outputs.JAVA_HOME }}
MVN_GPG_PASS: ${{ secrets.MVN_GPG_PASS }}
MVN_OSS_USER: ${{ secrets.MVN_OSS_USER }}
MVN_OSS_PASS: ${{ secrets.MVN_OSS_PASS }}
## maven deploy altrh
- name: Deploy ALT ${{ steps.settings.outputs.WINGS_VERSION }} ${{ steps.settings.outputs.GIT_BRANCH }}
if: steps.settings.outputs.MVN_DEPLOY_ALTRH == 'true'
continue-on-error: ${{ inputs.deployAltrh != 'true' }}
run: >
mvn
-P 'deploy,deploy-alt,deploy-old,!module-example,!module-devs'
${{ steps.settings.outputs.MVN_REVISION }}
-Dgpg.passphrase=${MVN_GPG_PASS}
-Dorg.slf4j.simpleLogger.log.lombok=WARN
-Dorg.slf4j.simpleLogger.log.org.jetbrains.dokka=WARN
-Dorg.slf4j.simpleLogger.log.pl.project13.maven.git=WARN
deploy
env:
JAVA_HOME: ${{ steps.settings.outputs.JAVA_HOME }}
MVN_GPG_PASS: ${{ secrets.MVN_GPG_PASS }}
## export MVN_ALT_REPO=https://packages.trydofor.com/maven/repository/devops/
MVN_ALT_USER: ${{ secrets.MVN_ALT_USER }}
MVN_ALT_PASS: ${{ secrets.MVN_ALT_PASS }}
MVN_ALT_REPO: ${{ secrets.MVN_ALT_REPO }}
MVN_ALT_SNAP: ${{ secrets.MVN_ALT_SNAP }}