-
Notifications
You must be signed in to change notification settings - Fork 153
245 lines (216 loc) · 8.69 KB
/
bld_mvn.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: bld_mvn
permissions:
checks: write
contents: read
issues: read
pull-requests: write
on:
workflow_call:
inputs:
version_tag:
description: 'Version tag to use: (bump must also be set to none to keep a specific version'
required: false
default: 'latest'
type: string
bump:
description: 'whether to bump the version number by a major minor patch'
required: false
default: 'patch'
type: string
ref:
description: 'git reference to use with the checkout use default_branch to have that calculated'
required: false
default: "default"
type: string
seed_maven_cache:
description: Whether to seed cache
type: boolean
required: false
default: true
install_maven_dependencies:
description: Whether to install dependencies or use a previous cache
type: boolean
required: false
default: true
deploy:
description: Whether to deploy the build to artifact repo
type: boolean
required: false
default: true
workflow_dispatch:
inputs:
version_tag:
description: 'Version tag to use: (bump must also be set to none to keep a specific version'
required: false
default: 'latest'
type: string
bump:
description: |
How to optionally bump the semver version ( Major.Minor.Patch ) : git log will be searched for
'#major #minor #patch' or feat/ or fix/ branch names to optionally override the bump. Set to none to keep a specific version
required: false
options:
- patch
- minor
- major
- none
type: choice
ref:
description: 'git reference to use with the checkout use default_branch to have that calculated'
required: false
default: "default"
type: string
seed_maven_cache:
description: Whether to seed cache
type: boolean
required: false
default: true
install_maven_dependencies:
description: Whether to install dependencies or use a previous cache
type: boolean
required: false
default: true
deploy:
description: Whether to deploy the build to artifact repo
type: boolean
required: false
default: true
jobs:
bld_mvn:
strategy:
matrix:
include:
- project: orcid-message-listener
- project: orcid-activemq
- project: orcid-api-web
- project: orcid-internal-api
- project: orcid-pub-web
- project: orcid-scheduler-web
- project: orcid-web
- project: orcid-utils
- project: orcid-core
- project: orcid-persistence
- project: orcid-api-common
runs-on: ubuntu-latest
steps:
- name: git-checkout-ref-action
id: ref
uses: ORCID/git-checkout-ref-action@main
with:
default_branch: ${{ github.event.repository.default_branch }}
ref: ${{ inputs.ref }}
- uses: actions/checkout@v4
with:
ref: ${{ steps.ref.outputs.ref }}
# checkout some history so we can scan commits for bump messages
# NOTE: history does not include tags!
fetch-depth: 100
- name: find next version
id: version
uses: ORCID/version-bump-action@main
with:
version_tag: ${{ inputs.version_tag }}
bump: ${{ inputs.bump }}
- name: Set up Open JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
######################################################################################################################
# handle restoring a custom gha cache
- name: if not installing dependencies restore special previous git_sha cache
if: ${{ ! inputs.install_maven_dependencies }}
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ steps.version.outputs.version_tag_numeric }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ steps.version.outputs.version_tag_numeric }}-${{ github.sha }}
- name: bump version of the parent pom and connected projects
if: ${{ ! inputs.install_maven_dependencies }}
run: |
mvn -T 1C --batch-mode versions:set -DskipTests \
-DnewVersion="$version_tag_numeric" -DgenerateBackupPoms=false
env:
version_tag_numeric: "${{ steps.version.outputs.version_tag_numeric }}"
########################################################################################
- name: if installing dependencies use a standard cache key name
if: ${{ inputs.install_maven_dependencies }}
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-seed-cache
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-seed-cache
- name: seed_maven_cache
if: ${{ inputs.seed_maven_cache }}
id: cache
uses: ORCID/ORCID-Source-cache-action@main
with:
version_tag_numeric: ${{ steps.version.outputs.version_tag_numeric }}
- name: install_dependencies and bump version
if: ${{ inputs.install_maven_dependencies }}
id: install_dependencies
uses: ORCID/ORCID-Source-dependencies-action@main
with:
version_tag_numeric: ${{ steps.version.outputs.version_tag_numeric }}
- name: build our project
run: |
mvn -T 1C --batch-mode -am package -DskipTests \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
--projects "$project"
echo "------------------------------------------------------"
find . -name '*.war'
find . -name '*.jar'
env:
project: "${{ matrix.project }}"
#
# orcid-web customization
#
- name: setup node for angular static file
if: ${{ matrix.project == 'orcid-web' }}
uses: actions/setup-node@v4
with:
node-version: 18.7.0
- name: build angular parts if we are building orcid-web
if: ${{ matrix.project == 'orcid-web' }}
run: |
echo "Build angular_orcid_generated.js"
cd orcid-nodejs
mvn -T 1C --batch-mode -P ci clean compile \
-Dnodejs.workingDirectory="${{ github.workspace }}/orcid-web/src/main/webapp/static/javascript/ng1Orcid" \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
echo "Copying angular_orcid_generated to its final destination"
cp ${{ github.workspace }}/orcid-web/src/main/webapp/static/javascript/ng1Orcid/angular_orcid_generated.js ${{ github.workspace }}/orcid-web/target/orcid-web/static/javascript/ng1Orcid/
echo "Packaging orcid-web"
rm -f ${{ github.workspace }}/orcid-web/target/orcid-web.war
cd ${{ github.workspace }}/orcid-web/target/orcid-web
# have a file on the webserver we can hit
echo "$version_tag_numeric" > ${{ github.workspace }}/orcid-web/target/orcid-web/static/version
echo "Creating the war file"
jar -cf orcid-web.war .
# check_error "Creating the orcid-web.war file"
echo "Moving war file to the target folder"
cp orcid-web.war ${{ github.workspace }}/orcid-web/target/
echo "orcid-web.war is ready"
env:
version_tag_numeric: "${{ steps.version.outputs.version_tag_numeric }}"
project: "${{ matrix.project }}"
##################################################################################################################
- name: deploy war file
if: ${{ inputs.deploy }}
run: |
mvn --batch-mode \
--settings settings-deploy.xml \
--file "${project}/pom.xml" \
-Dmaven.test.skip \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-DaltReleaseDeploymentRepository="github::${ARTIFACT_URL}${ARTIFACT_REPO_PATH}" \
deploy -Dmaven.test.skip
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
ARTIFACT_URL: "${{ secrets.ARTIFACT_URL }}"
ARTIFACT_REPO_PATH: "${{ secrets.ARTIFACT_REPO_PATH }}"
ARTIFACT_USER: "${{ secrets.ARTIFACT_USER }}"
ARTIFACT_PASSWORD: "${{ secrets.ARTIFACT_PASSWORD }}"
project: "${{ matrix.project }}"