-
Notifications
You must be signed in to change notification settings - Fork 10
153 lines (139 loc) · 5.09 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Release-To-OssRh
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
testVerifyDryRun:
description: 'dryrun coverage report?'
default: false
type: boolean
required: false
testLoggerLevel:
description: 'test logger level'
default: INFO
type: choice
options:
- DEBUG
- INFO
- WARN
- ERROR
deployOssrh:
description: 'deploy to ossrh?'
default: true
type: boolean
required: false
release:
types: [published]
push:
branches:
- 'main'
jobs:
release:
name: Release to Sonatype
runs-on: ubuntu-latest
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: |
JAVA_HOME=$(asdf where java)
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_OUTPUT"
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"
echo "MVN_REVISION=$_opt" >> "$GITHUB_OUTPUT"
fi
_ver=$(mvn --quiet --non-recursive -DforceStdout -Dexpression=project.version $_opt help:evaluate)
echo "WINGS_VERSION=$_ver"
echo "WINGS_VERSION=$_ver" >> "$GITHUB_OUTPUT"
_cov=${{ inputs.testCoverReport || github.event_name == 'push' }}
echo "MVN_COVERAGE=$_cov"
echo "MVN_COVERAGE=$_cov" >> "$GITHUB_OUTPUT"
_drh=${{ inputs.deployOssrh || github.event_name == 'release' }}
echo "MVN_DEPLOYRH=$_drh"
echo "MVN_DEPLOYRH=$_drh" >> "$GITHUB_OUTPUT"
mvn -v
git --no-pager log --graph -10 --pretty=format:'%H - %ai %d %s'
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
## 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 '!example,!devs' -Dmaven.test.skip=true clean install
mvn -pl ':devs-codegen' -Ddevs-initdb=true clean test
mvn -P 'coverage,!example,!devs' -Dmaven.test.failure.ignore=$TESTFAILS_IGNORE test
mvn -pl ':devs-coverage' -am jacoco:report-aggregate
mvn -pl ':devs-coverage' -DrepoToken=$COVERALLS_WINGS -DdryRun=$COVERALLS_DRYRUN verify
env:
TZ: Asia/Shanghai
JAVA_HOME: ${{ steps.settings.outputs.JAVA_HOME }}
COVERALLS_WINGS: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_DRYRUN: ${{ inputs.testVerifyDryRun || 'false' }}
TESTFAILS_IGNORE: ${{ inputs.testFailureIgnore || 'false' }}
## import gpp private key
- name: Import GPG key
if: steps.settings.outputs.MVN_DEPLOYRH == 'true'
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.MVN_GPG_SKEY }}
passphrase: ${{ secrets.MVN_GPG_PASS }}
## maven deploy
- name: Deploy ${{ steps.settings.outputs.WINGS_VERSION }} ${{ steps.settings.outputs.GIT_BRANCH }}
if: steps.settings.outputs.MVN_DEPLOYRH == 'true'
run: >
mvn
-P 'ossrh,doc,!example,!devs'
${{ steps.settings.outputs.MVN_REVISION }}
-Dgpg.passphrase=${MVN_GPG_PASS}
clean deploy
env:
JAVA_HOME: ${{ steps.settings.outputs.JAVA_HOME }}
MVN_OSS_USER: ${{ secrets.MVN_OSS_USER }}
MVN_OSS_PASS: ${{ secrets.MVN_OSS_PASS }}
MVN_GPG_PASS: ${{ secrets.MVN_GPG_PASS }}