-
Notifications
You must be signed in to change notification settings - Fork 12
483 lines (430 loc) · 19.7 KB
/
release-workflow.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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
name: Release ESMF SDK
on:
workflow_dispatch:
inputs:
release_version:
description: 'Version number of the release'
required: true
jobs:
check-preconditions:
name: Check preconditions
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
# Required for Maven
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
overwrite-settings: false
- name: Setup Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Sanity check version
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }}
run: |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
release_version=${{ github.event.inputs.release_version }}
if [[ $release_version =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]
then
echo version is valid
else
echo release version $release_version is invalid
exit 1
fi
shell: bash
# The Linux build will upload the local Nexus deployment repository
# (i.e., what will be deployed to OSSRH/Maven Central)
# and the Linux-specific samm-cli binary to the build artifacts
build-linux:
name: Linux build
needs: [check-preconditions]
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
# Even though the build itself is done using the GraalVM JDK
# (see below), we use the setup-java action to have GPG configured
# so that it can be used from the maven-gpg-plugin.
- name: Configure GPG
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
gpg-private-key: ${{ secrets.PGP_KEY }}
gpg-passphrase: PGP_KEY_PASSWORD
overwrite-settings: false
- name: Setup JDK
uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1.2.1
with:
java-version: '17.0.10'
distribution: 'graalvm'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set Swap Space (Linux)
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # master
with:
swap-size-gb: 12
# The Linux build will prepare a local Nexus staging repository
# that includes all .jars except the CLI jar
- name: Build and run tests
run: |
export MAVEN_OPTS="-Xmx4096m"
export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
# Required for reactor dependencies
mvn clean install -DskipTests -Dmaven.javadoc.skip=true
mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }}
mvn versions:commit
release_version=${{ github.event.inputs.release_version }}
# Actual build of core SDK
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean deploy -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 -DaltDeploymentRepository=local::default::file://nexus-staging -Psign
# Build of CLI
unset JAVA_TOOL_OPTIONS
mvn -B -pl tools/samm-cli clean verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
# Create .tar.gz of samm-cli
pushd tools/samm-cli/target
chmod a+x samm
tar cfvz samm-cli-${{ github.event.inputs.release_version }}-linux-x86_64.tar.gz samm *.so
popd
mv tools/samm-cli/target/samm-cli-${{ github.event.inputs.release_version }}-linux-x86_64.tar.gz .
cp tools/samm-cli/target/samm-cli-*.jar .
env:
PGP_KEY_PASSWORD: ${{ secrets.PGP_KEY_PASSWORD }}
- name: Switch to Temurin JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
overwrite-settings: false
- name: Test executable jar on Temurin
run: |
cd tools/samm-cli
mvn -B -Denforcer.skip -Dskip.maven.surefire failsafe:integration-test -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
- name: Upload staging directory and Linux binary
uses: actions/upload-artifact@v4
with:
name: linux-artifacts
path: |
nexus-staging/
samm-cli-${{ github.event.inputs.release_version }}-linux-x86_64.tar.gz
samm-cli-${{ github.event.inputs.release_version }}.jar
samm-cli-${{ github.event.inputs.release_version }}-javadoc.jar
samm-cli-${{ github.event.inputs.release_version }}-sources.jar
samm-cli-${{ github.event.inputs.release_version }}-tests.jar
build-macos:
name: Mac build
needs: [check-preconditions]
runs-on: macos-13
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1.2.1
with:
java-version: '17.0.10'
distribution: 'graalvm'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build and run tests
run: |
export MAVEN_OPTS="-Xmx4096m"
export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
# Required for reactor dependencies
mvn clean install -DskipTests -Dmaven.javadoc.skip=true
mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }}
mvn versions:commit
# Actual build of core SDK
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean install -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
# Build of CLI
unset JAVA_TOOL_OPTIONS
mvn -B -pl tools/samm-cli clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
shell: bash
- name: Build native executable
run: |
bundle="samm-bundle-$(date +%s)"
mkdir ${bundle}
curl -Lo jre.tar.gz https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.3%2B9/OpenJDK21U-jre_x64_mac_hotspot_21.0.3_9.tar.gz
tar -xvf jre.tar.gz
cp -r ./jdk-21.0.3+9-jre/Contents/Home ./${bundle}/jre
cp tools/samm-cli/target/samm-cli-${{ github.event.inputs.release_version }}.jar ./${bundle}/
cat <<EOF > ./${bundle}/run.sh
#!/usr/bin/env bash
HERE=\${BASH_SOURCE%/*}
"\$HERE/jre/bin/java" -jar "\$HERE/samm-cli-${{ github.event.inputs.release_version }}.jar" "\$@"
EOF
chmod +x ./${bundle}/run.sh
curl -Lo warp-packer https://github.com/dgiagio/warp/releases/download/v0.3.0/macos-x64.warp-packer
chmod +x warp-packer
./warp-packer --arch macos-x64 --input_dir ${bundle} --exec run.sh --output samm
chmod a+x samm
tar cfvz samm-cli-${{ github.event.inputs.release_version }}-macos-x86_64.tar.gz samm
shell: bash
- name: Upload Mac binary
uses: actions/upload-artifact@v4
with:
name: mac-artifacts
path: |
samm-cli-${{ github.event.inputs.release_version }}-macos-x86_64.tar.gz
# The Windows build will build the Windows-specific samm-cli
# and upload the binary to the build artifacts
build-windows:
name: Windows build
needs: [check-preconditions]
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1.2.1
with:
java-version: '17.0.10'
distribution: 'graalvm'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Configure Pagefile (Windows)
# Fix for "LINK : fatal error LNK1171: unable to load mspdbcore.dll (error code: 1455)":
# This seems to be caused by running out of memory; increasing page file
# size suggested here:
# https://github.com/actions/virtual-environments/issues/3420#issuecomment-861342418
uses: al-cheb/configure-pagefile-action@86589fd789a4de3e62ba628dda2cb10027b66d67 # v1.3
with:
minimum-size: 32GB
maximum-size: 32GB
disk-root: "C:"
- name: Build and run tests
run: |
export MAVEN_OPTS="-Xmx4096m"
export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
# Required for reactor dependencies
mvn clean install -DskipTests -Dmaven.javadoc.skip=true
mvn versions:set -DnewVersion=${{ github.event.inputs.release_version }}
mvn versions:commit
# Actual build of core SDK
mvn -B -pl '!org.eclipse.esmf:samm-cli' clean install -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
# Build of CLI
unset JAVA_TOOL_OPTIONS
mvn -B -pl tools/samm-cli clean verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
shell: bash
- name: Upload Windows binary
uses: actions/upload-artifact@v4
with:
name: windows-artifacts
path: |
tools/samm-cli/target/samm.exe
tools/samm-cli/target/*.dll
tools/samm-cli/target/lib/
release:
name: Release
needs: [build-linux, build-windows, build-macos]
runs-on: ubuntu-latest
steps:
# Need to checkout here too, so that we have the pom.xml
# with the deployment info available
- name: Checkout
uses: actions/checkout@v4
# Required to have Maven settings.xml set up correctly
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_TOKEN
overwrite-settings: false
# Required to run the mvn:versions, since enforcer plugin
# will check for GraalVM JDK
- name: Setup JDK
uses: graalvm/setup-graalvm@2f25c0caae5b220866f732832d5e3e29ff493338 # v1.2.1
with:
java-version: '17.0.10'
distribution: 'graalvm'
components: 'native-image,js'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'false'
- name: Fetch Linux Artifacts
uses: actions/download-artifact@v4
with:
name: linux-artifacts
- name: Fetch Mac Artifacts
uses: actions/download-artifact@v4
with:
name: mac-artifacts
- name: Set versions
continue-on-error: true
run: |
release_version=${{ github.event.inputs.release_version }}
release_branch_name=${release_version%.*}.x
echo "release_branch_name=$release_branch_name" >> $GITHUB_ENV
# Set version in pom.xml files
mvn -B clean install -DskipTests -Dmaven.javadoc.skip=true
mvn -B versions:set -DnewVersion=${{ github.event.inputs.release_version }}
mvn -B versions:commit
# Set version in Antora module
yq eval -i '.version = "${{ github.event.inputs.release_version }}"' documentation/developer-guide/antora.yml
- name: Commit version changes and push to upstream repository
uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d # v5
with:
branch: ${{ env.release_branch_name }}
commit_user_name: github-actions
commit_user_email: [email protected]
commit_author: Author <[email protected]>
file_pattern: 'documentation/developer-guide/antora.yml pom.xml */pom.xml */*/pom.xml'
# Full release: Github
- name: "Create Github release (full)"
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }}
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
body: "Release version ${{ github.event.inputs.release_version }}."
tag_name: v${{ github.event.inputs.release_version }}
target_commitish: ${{ env.release_branch_name }}
draft: false
prerelease: false
files: |
samm-cli-${{ github.event.inputs.release_version }}-linux-x86_64.tar.gz
samm-cli-${{ github.event.inputs.release_version }}-macos-x86_64.tar.gz
samm-cli-*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Notify issues of release their fix is contained in"
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }}
uses: apexskier/github-release-commenter@3bd413ad5e1d603bfe2282f9f06f2bdcec079327 # v1.3.6
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment-template: |
Release {release_link} addresses this.
# Sign SAML-CLI Windows executable
- name: Get Artifact ID (Windows)
shell: bash
run: |
# Get the list of artifacts for the specified workflow run
response=$(curl -H "Authorization: Bearer $TOKEN" -H "Accept: application/vnd.github+json" "https://api.github.com/repos/${{ github.repository_owner }}/$(echo '${{ github.repository }}' | cut -d'/' -f2)/actions/runs/${{ github.run_id }}/artifacts")
# Filter out the ID of the artifact with a name that contains "windows"
artifact_id=$(echo "$response" | jq -r '.artifacts[] | select(.name | contains("windows-artifacts")) | .id')
# Save the artifact ID in an environment variable
echo "ARTIFACT_ID=$artifact_id" >> $GITHUB_ENV
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit Artifact URL and version changes and push to pre release branch for Jenkins (Windows)
shell: bash
run: |
ARTIFACT_URL_WIN="https://api.github.com/repos/eclipse-esmf/esmf-sdk/actions/artifacts/$ARTIFACT_ID/zip"
BRANCH_NAME="pre_release_configuration"
echo "artifact_url_win=$ARTIFACT_URL_WIN" > parameters.txt
echo "version=${{ github.event.inputs.release_version }}" >> parameters.txt
git config --global user.email "[email protected]"
git config --global user.name "github-actions"
git checkout -b $BRANCH_NAME
git add parameters.txt
git commit -m "Add parameters.txt with artifact_url_win and version"
git push origin $BRANCH_NAME
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger Jenkins Job, for signing executable
shell: bash
run: |
DATA='{"repository": {"url": "https://github.com/eclipse-esmf/esmf-sdk", "html_url": "https://github.com/eclipse-esmf/esmf-sdk", "owner": { "name": "ESMF"}}, "pusher": { "name": "GitHub Action", "email": "[email protected]"}}'
SHA1="$(echo -n "${DATA}" | openssl dgst -sha1 -hmac "${WEBHOOK_SECRET}" | sed 's/SHA1(stdin)= //')"
curl -X POST https://ci.eclipse.org/esmf/github-webhook/ -H "Content-Type: application/json" -H "X-GitHub-Event: push" -H "X-Hub-Signature: sha1=${SHA1}" -d "${DATA}"
# Full release: Maven Central
# The (apparently) only way to retrieve the staging profile id
# is the undocumented rc-list-profiles command of the
# nexus-staging-maven-plugin:
# mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13:rc-list-profiles -DnexusUrl=https://oss.sonatype.org/ -DserverId=ossrh
- name: Release to OSSRH/Maven Central
if: ${{ !contains( github.event.inputs.release_version, '-M' ) }}
run: |
mkdir deploy
mv nexus-staging deploy
cd deploy
mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.13:deploy-staged-repository \
-DnexusUrl=https://oss.sonatype.org/ \
-DserverId=ossrh \
-DrepositoryDirectory=nexus-staging \
-DstagingProfileId=7e73217781f2e
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
# Workaround for https://issues.sonatype.org/browse/OSSRH-66257
# as described in https://stackoverflow.com/a/70157413
MAVEN_OPTS: --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED
# Milestone release: Write settings to deploy to Github repo
- name: Write settings.xml
if: contains( github.event.inputs.release_version, '-M' )
uses: DamianReeves/write-file-action@0a7fcbe1960c53fc08fe789fa4850d24885f4d84 # v1.2
with:
path: settings.xml
contents: |
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<value>Bearer ${env.GITHUB_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
<server>
<id>gpg.passphrase</id>
<passphrase>${env.PGP_KEY_PASSWORD}</passphrase>
</server>
</servers>
</settings>
write-mode: overwrite
# Milestone release: Maven deploy to Github
- name: Publish to Github
if: contains( github.event.inputs.release_version, '-M' )
run: mvn -s ./settings.xml -B clean -pl '!esmf-sdk-test-report,!documentation,!tools/samm-cli' deploy -DskipTests -Pmilestone-build,sign
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PGP_KEY_PASSWORD: ${{ secrets.PGP_KEY_PASSWORD }}
# Milestone release: Github
- name: "Create Github release (milestone)"
if: contains( github.event.inputs.release_version, '-M' )
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
body: "Release version ${{ github.event.inputs.release_version }}."
tag_name: v${{ github.event.inputs.release_version }}
target_commitish: ${{ env.release_branch_name }}
draft: false
prerelease: true
files: |
samm-cli-${{ github.event.inputs.release_version }}-linux-x86_64.tar.gz
samm-cli-${{ github.event.inputs.release_version }}-macos-x86_64.tar.gz
samm-cli-*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}