-
Notifications
You must be signed in to change notification settings - Fork 12
384 lines (345 loc) · 15.1 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
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
# 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@b8dc5fccfbc65b21dd26e8341e7b21c86547f61b # v1
with:
java-version: '17.0.8'
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 -Dmaven.wagon.httpconnectionManager.ttlSeconds=60 -DaltDeploymentRepository=local::default::file://nexus-staging -Psign
# Build of CLI
pushd tools/samm-cli
unset JAVA_TOOL_OPTIONS
mvn -B clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
mvn -B verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
popd
# 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
# 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@b8dc5fccfbc65b21dd26e8341e7b21c86547f61b # v1
with:
java-version: '17.0.8'
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 -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
# Build of CLI
cd tools/samm-cli
unset JAVA_TOOL_OPTIONS
mvn -B clean verify -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
mvn -B verify -Pnative -Dmaven.wagon.httpconnectionManager.ttlSeconds=60
echo "start cmd /k samm.exe help" > tools/samm-cli/target/start-samm-cli.bat
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/*.bat
tools/samm-cli/target/*.dll
tools/samm-cli/target/lib/
release:
name: Release
needs: [build-linux, build-windows]
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@b8dc5fccfbc65b21dd26e8341e7b21c86547f61b # v1
with:
java-version: '17.0.8'
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 Windows Artifacts
uses: actions/download-artifact@v4
with:
name: windows-artifacts
- name: Prepare release
run: |
# Create Windows CLI zip
zip -9 -r samm-cli-${{ github.event.inputs.release_version }}-windows-x86_64.zip samm.exe *.bat *.dll
# 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
- 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 }}-windows-x86_64.zip
samm-cli-${{ github.event.inputs.release_version }}-linux-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.
# 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 }}-windows-x86_64.zip
samm-cli-${{ github.event.inputs.release_version }}-linux-x86_64.tar.gz
samm-cli-*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}