-
Notifications
You must be signed in to change notification settings - Fork 2
448 lines (397 loc) · 16.4 KB
/
maven-cli.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
tags:
- 'v*'
jobs:
build-jar-job:
name: 'Build Runnable JAR'
runs-on: ubuntu-latest
steps:
- name: checkout from git
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: 'Get Version from tag'
uses: olegtarasov/get-tag@v2.1.2
id: tagName
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- id: build_jar
name: Build JARs
env:
OPENEPCIS_OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OPENEPCIS_OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
run: |
mvn \
-s .mvn/settings.xml \
--no-transfer-progress \
--batch-mode -Pcli-build \
clean package
- name: 'Get Version Number'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
echo "::set-env name=VERSION::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
- name: 'Publish CLI JAR'
uses: actions/upload-artifact@v3
with:
name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar'
path: 'cli/target/openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar'
- name: 'Create Release'
if: contains(github.ref, 'v')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{github.ref}}
release_name: Release ${{github.ref}}
body: |
Initial release
draft: false
prerelease: false
- name: 'Upload Release Service Asset'
if: contains(github.ref, 'v')
id: upload-service-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: 'quarkus-app/target/openepcis-event-hash-generator-service-runner.jar'
asset_name: 'openepcis-event-hash-generator-service-${{env.GIT_TAG_NAME}}.jar'
asset_content_type: application/java-archive
- name: 'Upload Release CLI Asset'
if: contains(github.ref, 'v')
id: upload--cli-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: 'cli/target/openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar'
asset_name: 'openepcis-event-hash-generator-cli-${{env.GIT_TAG_NAME}}.jar'
asset_content_type: application/java-archive
- name: 'Write Upload URL To File'
if: contains(github.ref, 'v')
run: |
echo "${{steps.create_release.outputs.upload_url}}" > upload_url.txt
- name: 'Publish Upload URL'
if: contains(github.ref, 'v')
uses: actions/upload-artifact@v3
with:
name: 'upload_url.txt'
path: 'upload_url.txt'
build-quarkus-native-container-images:
name: "Build Native Container Image"
strategy:
matrix:
os: ['ubuntu-latest', 'ubuntu-22.04-arm64']
include:
- os: 'ubuntu-latest'
label: 'linux-amd64'
platform: "linux/amd64"
tags: "latest-amd64"
jib-platforms: "linux/amd64"
- os: 'ubuntu-22.04-arm64'
label: 'linux-arm64'
platform: "linux/arm64"
tags: "latest-arm64"
jib-platforms: "linux/arm64/v8"
runs-on: ${{matrix.os}}
steps:
- name: checkout from git
uses: actions/checkout@v3
- name: 'Get Version from tag'
uses: olegtarasov/get-tag@v2.1.2
id: tagName
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: "Prepare Build"
run: >
mvn --no-transfer-progress --batch-mode -Pci-build clean package -DskipTests
- name: "Build ${{matrix.platform}} native Image"
run: |
mvn --no-transfer-progress --batch-mode -Pci-build package -Dnative -DskipTests -f ./quarkus-app/pom.xml \
-Dquarkus.native.container-build=true \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.name=event-hash-generator-service-native \
-Dquarkus.container-image.registry=ghcr.io \
-Dquarkus.container-image.group=openepcis \
-Dquarkus.container-image.additional-tags=${{matrix.tags}},${GIT_TAG_NAME}-${{matrix.label}} \
-Dquarkus.native.container-runtime-options="--platform=${{matrix.platform}}" \
-Dquarkus.jib.platforms=${{matrix.jib-platforms}}
- name: "push arch image"
run: |
docker push ghcr.io/openepcis/event-hash-generator-service-native:${GIT_TAG_NAME}-${{matrix.label}};
docker push ghcr.io/openepcis/event-hash-generator-service-native:${{matrix.tags}};
push-quarkus-native-container-images:
name: "Push Native Container Images"
needs: [build-quarkus-native-container-images]
runs-on: 'ubuntu-latest'
steps:
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: 'Get Version from tag'
uses: olegtarasov/get-tag@v2.1.2
id: tagName
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- name: "push multi-arch image"
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled;
docker manifest create ghcr.io/openepcis/event-hash-generator-service-native:${GIT_TAG_NAME} \
--amend ghcr.io/openepcis/event-hash-generator-service-native:${GIT_TAG_NAME}-linux-amd64 \
--amend ghcr.io/openepcis/event-hash-generator-service-native:${GIT_TAG_NAME}-linux-arm64;
docker manifest push ghcr.io/openepcis/event-hash-generator-service-native:${GIT_TAG_NAME};
docker manifest create ghcr.io/openepcis/event-hash-generator-service-native:latest \
--amend ghcr.io/openepcis/event-hash-generator-service-native:latest-amd64 \
--amend ghcr.io/openepcis/event-hash-generator-service-native:latest-arm64;
docker manifest push ghcr.io/openepcis/event-hash-generator-service-native:latest;
build-quarkus-container-images:
name: "Build Container Images"
runs-on: 'ubuntu-latest'
steps:
- name: checkout from git
uses: actions/checkout@v3
- name: 'Get Version from tag'
uses: olegtarasov/get-tag@v2.1.2
id: tagName
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- name: docker hub
uses: docker/login-action@v1
with:
username: ${{ secrets.OPENEPCIS_DOCKER_USER }}
password: ${{ secrets.OPENEPCIS_DOCKER_TOKEN }}
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: builder
uses: docker/setup-buildx-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: "Prepare Build"
run: >
mvn --no-transfer-progress --batch-mode -Pci-build clean package -DskipTests
- name: "Build linux/amd64 Image"
run: |
mvn --no-transfer-progress --batch-mode \
clean package -Pci-build -f ./quarkus-app/pom.xml \
-Dquarkus.container-image.name=event-hash-generator-service \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.registry=ghcr.io \
-Dquarkus.container-image.group=openepcis \
-Dquarkus.jib.base-jvm-image=eclipse-temurin:21-jre-alpine \
-Dquarkus.container-image.additional-tags=latest-amd64,${GIT_TAG_NAME}-amd64 \
-Dquarkus.jib.platforms=linux/amd64
- name: "Build linux/arm64 Image"
run: |
mvn --no-transfer-progress --batch-mode \
clean package -Pci-build -f ./quarkus-app/pom.xml \
-Dquarkus.container-image.name=event-hash-generator-service \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.registry=ghcr.io \
-Dquarkus.container-image.group=openepcis \
-Dquarkus.jib.base-jvm-image=eclipse-temurin:21-jre-alpine \
-Dquarkus.container-image.additional-tags=latest-arm64,${GIT_TAG_NAME}-arm64 \
-Dquarkus.jib.platforms=linux/arm64/v8
- name: "push multi arch image"
run: |
docker push ghcr.io/openepcis/event-hash-generator-service:${GIT_TAG_NAME}-amd64;
docker push ghcr.io/openepcis/event-hash-generator-service:${GIT_TAG_NAME}-arm64;
docker push ghcr.io/openepcis/event-hash-generator-service:latest-amd64;
docker push ghcr.io/openepcis/event-hash-generator-service:latest-arm64;
export DOCKER_CLI_EXPERIMENTAL=enabled;
docker manifest create ghcr.io/openepcis/event-hash-generator-service:${GIT_TAG_NAME} \
--amend ghcr.io/openepcis/event-hash-generator-service:${GIT_TAG_NAME}-amd64 \
--amend ghcr.io/openepcis/event-hash-generator-service:${GIT_TAG_NAME}-arm64;
docker manifest push ghcr.io/openepcis/event-hash-generator-service:${GIT_TAG_NAME};
docker manifest create ghcr.io/openepcis/event-hash-generator-service:latest \
--amend ghcr.io/openepcis/event-hash-generator-service:latest-amd64 \
--amend ghcr.io/openepcis/event-hash-generator-service:latest-arm64;
docker manifest push ghcr.io/openepcis/event-hash-generator-service:latest;
build-quarkus-native-executable:
name: "Build Quarkus Service Native Executable"
needs: [build-jar-job]
strategy:
matrix:
os: ['ubuntu-latest', 'ubuntu-22.04-arm64', 'macos-latest', 'windows-latest']
include:
- os: 'ubuntu-latest'
label: 'linux-amd64'
exe: ""
- os: 'ubuntu-22.04-arm64'
label: 'linux-arm64'
exe: ""
- os: 'macos-latest'
label: 'mac'
exe: ""
- os: 'windows-latest'
label: 'windows'
exe: ".exe"
runs-on: ${{matrix.os}}
steps:
- name: checkout from git
uses: actions/checkout@v3
- name: 'Get Version from tag'
uses: olegtarasov/get-tag@v2.1.2
id: tagName
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- name: 'Download Release URL'
if: contains(github.ref, 'v')
uses: actions/download-artifact@v3
with:
name: 'upload_url.txt'
- name: 'Set Upload URL Env Var'
if: contains(github.ref, 'v')
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
echo "::set-env name=UPLOAD_URL::$(cat upload_url.txt)"
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm-community'
native-image-job-reports: 'true'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "Prepare Build"
run: |
mvn --no-transfer-progress --batch-mode -Pci-build clean package -DskipTests
- name: "Build Native Quarkus Executable"
run: |
mvn --no-transfer-progress --batch-mode clean package -Pnative -Pci-build -DskipTests -f ./quarkus-app/pom.xml
- name: 'Release Native Quarkus Executable'
if: success() && contains(github.ref, 'v')
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{env.UPLOAD_URL}}
asset_name: 'openepcis-event-hash-generator-service-runner-${{env.GIT_TAG_NAME}}-${{matrix.label}}${{matrix.exe}}'
asset_path: 'quarkus-app/target/openepcis-event-hash-generator-service-runner${{matrix.exe}}'
asset_content_type: application/octet-stream
build-cli-native-executable:
name: 'Build CLI Native Executable'
needs: [build-jar-job]
strategy:
matrix:
os: ['ubuntu-latest', 'ubuntu-22.04-arm64', 'macos-latest', 'windows-latest']
include:
- os: 'ubuntu-latest'
label: 'linux-amd64'
exe: ""
- os: 'ubuntu-22.04-arm64'
label: 'linux-arm64'
exe: ""
- os: 'macos-latest'
label: 'mac'
exe: ""
- os: 'windows-latest'
label: 'windows'
exe: ".exe"
runs-on: ${{matrix.os}}
steps:
- name: checkout from git
uses: actions/checkout@v3
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm-community'
native-image-job-reports: 'true'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: 'Get Version Number'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
echo "::set-env name=VERSION::$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
shell: bash
- name: 'Get Version from tag'
uses: olegtarasov/get-tag@v2.1.2
id: tagName
with:
tagRegex: "v(.*)"
tagRegexGroup: 1
- name: 'Get JAR Artifact'
uses: actions/download-artifact@v3
with:
name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar'
- name: 'Download Release URL'
if: contains(github.ref, 'v')
uses: actions/download-artifact@v3
with:
name: 'upload_url.txt'
- name: 'Set Upload URL Env Var'
if: contains(github.ref, 'v')
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
echo "::set-env name=UPLOAD_URL::$(cat upload_url.txt)"
- name: 'Build Native CLI Image'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
native-image --no-server --no-fallback --enable-http --enable-https --allow-incomplete-classpath -H:+JNI -H:+UseServiceLoaderFeature -H:ReflectionConfigurationFiles=./cli/src/native/resources/reflect.json -jar openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies.jar
- name: 'Publish Native CLI Image'
if: success()
uses: actions/upload-artifact@v3
with:
name: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-${{matrix.label}}${{matrix.exe}}'
path: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies${{matrix.exe}}'
- name: 'Release Native Image Asset'
if: success() && contains(github.ref, 'v')
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{env.UPLOAD_URL}}
asset_name: 'openepcis-event-hash-generator-cli-${{env.GIT_TAG_NAME}}-${{matrix.label}}${{matrix.exe}}'
asset_path: 'openepcis-event-hash-generator-cli-${{env.VERSION}}-jar-with-dependencies${{matrix.exe}}'
asset_content_type: application/octet-stream