Repository navigation
402 lines (344 loc) · 15.7 KB
/
Copy pathbuild-macos.yml
File metadata and controls
402 lines (344 loc) · 15.7 KB
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
name: Build MacOS Release Artifacts
on:
workflow_call:
inputs:
artifact_basename:
description: 'Base name for all build artifacts (e.g., hdfview-master-abc1234 or HDFView-3.4.0)'
type: string
required: true
build_type:
description: 'Build type: release, pre-release, or snapshot'
type: string
required: false
default: 'snapshot'
hdf4_release_tag:
description: 'HDF4 GitHub release tag to download from (e.g., snapshot, hdf4.3.1)'
type: string
required: false
default: 'snapshot'
hdf4_artifact_basename:
description: 'HDF4 artifact base filename pattern (e.g., hdf4.3.1, hdf-master-abc1234)'
type: string
required: false
default: 'snapshot'
hdf5_release_tag:
description: 'HDF5 GitHub release tag to download from (e.g., snapshot, 2.0.0)'
type: string
required: false
default: 'snapshot'
hdf5_artifact_basename:
description: 'HDF5 artifact base filename pattern (e.g., 2.0.0, hdf5-develop-xyz7890)'
type: string
required: false
default: 'snapshot'
hdf4_version:
description: 'HDF4 version number (e.g., 4.3.1) - if provided, skips parsing from JAR filename'
type: string
required: false
default: ''
hdf5_version:
description: 'HDF5 version number (e.g., 2.0.0) - if provided, skips parsing from JAR filename'
type: string
required: false
default: ''
hdf5_prefix:
description: 'Prefix for HDF5 release file patterns: "" for snapshot, "hdf5-" for tagged releases'
type: string
required: false
default: ''
permissions:
contents: read
packages: write
jobs:
build-macos-app:
name: Build macOS App Image (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
strategy:
matrix:
include:
- arch: x86_64
runner: macos-15-intel
- arch: arm64
runner: macos-15
env:
KEYCHAIN_NAME: ${{ vars.KEYCHAIN_NAME }}
SIGNER: ${{ vars.SIGNER }}
NOTARY_USER: ${{ vars.NOTARY_USER }}
NOTARY_KEY: ${{ secrets.NOTARY_KEY }}
APPLE_CERTS_BASE64: ${{ secrets.APPLE_CERTS_BASE64 }}
APPLE_CERTS_BASE64_PASSWD: ${{ secrets.APPLE_CERTS_BASE64_PASSWD }}
KEYCHAIN_PASSWD: ${{ secrets.KEYCHAIN_PASSWD }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from VERSION file
id: get-version
run: |
HDFVIEW_VERSION=$(grep "^HDFVIEW_VERSION=" VERSION | cut -d'=' -f2)
echo "HDFVIEW_VERSION=$HDFVIEW_VERSION" >> $GITHUB_OUTPUT
echo "HDFView version: $HDFVIEW_VERSION"
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven Dependencies
uses: actions/cache@v4
with:
path: |
~/.m2/repository
!~/.m2/repository/org/hdfgroup
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Download and Install HDF4 from GitHub
run: |
PATTERN="${{ inputs.hdf4_artifact_basename }}-macos14_clang.tar.gz"
echo "Using pattern: $PATTERN"
gh release download "${{ inputs.hdf4_release_tag }}" --repo HDFGroup/hdf4 --pattern "$PATTERN" \
--clobber
tar -zxvf *-macos14_clang.tar.gz
[ -d hdf4 ] || mv hdf4-* hdf4
cd hdf4
tar -zxvf HDF-*-Darwin.tar.gz --strip-components 1
HDF4DIR=${{ github.workspace }}/hdf4/HDF_Group/HDF/
FILE_NAME=$(ls $HDF4DIR)
echo "HDF4LIB_PATH=$HDF4DIR$FILE_NAME" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ github.token }}
- name: Download and Install HDF5 from GitHub
run: |
PATTERN="${{ inputs.hdf5_prefix }}${{ inputs.hdf5_artifact_basename }}-macos15_clang.tar.gz"
echo "Using pattern: $PATTERN"
gh release download "${{ inputs.hdf5_release_tag }}" --repo HDFGroup/hdf5 --pattern "$PATTERN" \
--clobber
tar -zxvf hdf5-*-macos15_clang.tar.gz
[ -d hdf5 ] || mv hdf5-* hdf5
cd hdf5
tar -zxvf HDF5-*-Darwin.tar.gz --strip-components 1
HDF5DIR=${{ github.workspace }}/hdf5/HDF_Group/HDF5/
FILE_NAME=$(ls $HDF5DIR)
echo "HDF5LIB_PATH=$HDF5DIR$FILE_NAME" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ github.token }}
- name: Set up build.properties
run: |
cat > build.properties <<EOF
hdf5.lib.dir=${{ env.HDF5LIB_PATH }}/lib
hdf5.plugin.dir=${{ env.HDF5LIB_PATH }}/lib/plugin
hdf.lib.dir=${{ env.HDF4LIB_PATH }}/lib
platform.hdf.lib=${{ env.HDF5LIB_PATH }}/lib
EOF
- name: Install HDF5 JAR to Local Maven Repository
run: |
mkdir -p repository/lib
cp ${{ env.HDF5LIB_PATH }}/lib/*.jar repository/lib/ 2>/dev/null || echo "No HDF5 JARs"
cd repository/lib
if [ ! -f jarhdf5-*.jar ]; then
echo "Error: jarhdf5 JAR file not found!"
exit 1
fi
JAR_FILE=$(ls jarhdf5-*.jar | head -1)
HDF5_VERSION=$(echo "$JAR_FILE" | sed -n 's/.*jarhdf5-\([0-9.]*\)\.jar/\1/p')
mvn install:install-file -Dfile="$JAR_FILE" -DgroupId=jarhdf5 -DartifactId=jarhdf5 -Dversion="$HDF5_VERSION" -Dpackaging=jar -DgeneratePom=true
echo "Installed: $JAR_FILE as version $HDF5_VERSION"
- name: Install HDF4 JAR to Local Maven Repository
run: |
cp ${{ env.HDF4LIB_PATH }}/lib/*.jar repository/lib/ 2>/dev/null || echo "No HDF4 JARs"
cd repository/lib
if [ ! -f jarhdf-*.jar ]; then
echo "Error: jarhdf (hdf4) JAR file not found!"
exit 1
fi
JAR_FILE=$(ls jarhdf-*.jar | head -1)
HDF4_VERSION=$(echo "$JAR_FILE" | sed -n 's/.*jarhdf-\([0-9.]*\)\.jar/\1/p')
mvn install:install-file -Dfile="$JAR_FILE" -DgroupId=jarhdf -DartifactId=jarhdf -Dversion="$HDF4_VERSION" -Dpackaging=jar -DgeneratePom=true
echo "Installed: $JAR_FILE as version $HDF4_VERSION"
- name: Install SWTBot JARs to Local Maven Repository
run: |
echo "Installing SWTBot JARs to local Maven repository..."
# TODO - hardcoded dependency files in repository/lib will likely break over time
cd repository/lib
if [ ! -f org.eclipse.swtbot.jar ]; then
echo "Error: org.eclipse.swtbot.jar file not found in repository/lib/"
exit 1
fi
mvn install:install-file -Dfile=org.eclipse.swtbot.swt.finder.jar \
-DgroupId=org.eclipse.local \
-DartifactId=org.eclipse.swtbot.swt.finder \
-Dversion=4.2.1 \
-Dpackaging=jar \
-DgeneratePom=true
echo "SWTBot SWT finder JAR installed"
if [ ! -f org.eclipse.swtbot.nebula.nattable.finder.jar ]; then
echo "Error: org.eclipse.swtbot.nebula.nattable.finder.jar file not found in repository/lib/"
exit 1
fi
mvn install:install-file -Dfile=org.eclipse.swtbot.nebula.nattable.finder.jar \
-DgroupId=org.eclipse.local \
-DartifactId=org.eclipse.swtbot.nebula.nattable.finder \
-Dversion=4.2.1 \
-Dpackaging=jar \
-DgeneratePom=true
echo "SWTBot Nebula NatTable finder JAR installed"
- name: Setup Keychain for Code Signing
if: github.repository == 'HDFGroup/hdfview' && env.APPLE_CERTS_BASE64 != ''
run: |
echo "Setting up temporary keychain for code signing..."
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_FILE=$KEYCHAIN_NAME.keychain
echo $APPLE_CERTS_BASE64 | base64 --decode > $CERTIFICATE_PATH
security -v create-keychain -p $KEYCHAIN_PASSWD $KEYCHAIN_FILE
security -v list-keychain -d user -s $KEYCHAIN_FILE
security -v list-keychains
security -v set-keychain-settings -lut 21600 $KEYCHAIN_FILE
security -v unlock-keychain -p $KEYCHAIN_PASSWD $KEYCHAIN_FILE
security -v import $CERTIFICATE_PATH -P $APPLE_CERTS_BASE64_PASSWD -A -t cert -f pkcs12 -k $KEYCHAIN_FILE
security -v set-key-partition-list -S apple-tool:,codesign:,apple: -k $KEYCHAIN_PASSWD $KEYCHAIN_FILE
rm $CERTIFICATE_PATH
echo "✓ Keychain setup complete"
echo "✓ Code signing identity: $SIGNER"
- name: Create App Image + Install with Maven Profile
run: |
# Conditionally add signing profile if on canonical repo with certs
if [[ "${{ github.repository }}" == "HDFGroup/hdfview" && -n "${{ env.APPLE_CERTS_BASE64 }}" ]]; then
SIGN_PROFILE=",jpackage-mac-sign"
SIGN_STATUS="signed"
else
SIGN_PROFILE=""
SIGN_STATUS="unsigned"
fi
echo "Creating ${{ matrix.arch }} app-image using Maven jpackage profile ($SIGN_STATUS)..."
# Step 1: Install repository module
echo "Installing repository module..."
mvn clean install -DskipTests \
-Djacoco.skip=true \
-Dpmd.skip=true \
-Ddependency-check.skip=true \
-pl repository \
-B
# Step 2: Install all modules (including parent POM)
echo "Installing all modules..."
mvn clean install -DskipTests \
-Djacoco.skip=true \
-Dpmd.skip=true \
-Ddependency-check.skip=true \
-B
# Step 3: Package
echo "Packaging..."
mvn package -DskipTests \
-Djacoco.skip=true \
-Dpmd.skip=true \
-Ddependency-check.skip=true \
-B
# Step 4: Run verify phase with jpackage profiles to create app-image
echo "Running verify phase with jpackage profiles to create app-image..."
mvn verify -Pjpackage-app-image,jpackage-mac-base${SIGN_PROFILE} \
-pl hdfview \
-DskipTests \
-Djacoco.skip=true \
-Dpmd.skip=true \
-Ddependency-check.skip=true \
-B
if [ -d hdfview/target/dist/HDFView.app ]; then
echo "✓ ${{ matrix.arch }} app-image created successfully ($SIGN_STATUS)"
echo "App size: $(du -sh hdfview/target/dist/HDFView.app | cut -f1)"
else
echo "✗ app-image creation failed"
exit 1
fi
- name: Create Application Archive
run: |
cd hdfview/target/dist
tar -czf ${{ github.workspace }}/HDFView-${{ steps.get-version.outputs.HDFVIEW_VERSION }}App-Darwin-${{ matrix.arch }}.tar.gz HDFView.app/
echo "Created ${{ matrix.arch }} archive: HDFView-${{ steps.get-version.outputs.HDFVIEW_VERSION }}App-Darwin-${{ matrix.arch }}.tar.gz"
- name: Upload Application Archive as Artifact
uses: actions/upload-artifact@v4
with:
name: macos-app-${{ matrix.arch }}
path: HDFView-*App-Darwin-${{ matrix.arch }}.tar.gz
retention-days: 30
- name: Set target DMG name
run: |
echo "STANDARD_DMG_NAME=HDFView-${{ steps.get-version.outputs.HDFVIEW_VERSION }}-Darwin-${{ matrix.arch }}.dmg" >> $GITHUB_ENV
- name: Create and Sign DMG Installer
run: |
# Determine if we should sign the DMG
if [[ "${{ github.repository }}" == "HDFGroup/hdfview" && -n "${{ env.APPLE_CERTS_BASE64 }}" ]]; then
SHOULD_SIGN=true
SIGN_STATUS="signed"
else
SHOULD_SIGN=false
SIGN_STATUS="unsigned"
fi
echo "Creating DMG installer for ${{ matrix.arch }} ($SIGN_STATUS)..."
# Use Maven jpackage-installer-mac profile (creates HDFView-{VERSION}.dmg)
mvn package -Pjpackage-installer-mac -pl hdfview -DskipTests -B
# Rename to standard format
cd hdfview/target/dist
DMG_FILE=$(ls *.dmg)
mv "$DMG_FILE" "$STANDARD_DMG_NAME"
echo "✓ DMG renamed to: $STANDARD_DMG_NAME"
ls -lh *.dmg
# Conditionally sign the DMG (only on canonical repo with certs)
if [ "$SHOULD_SIGN" = true ]; then
echo "Signing DMG..."
codesign --force --sign "The HDF Group ($SIGNER)" \
--options runtime \
--timestamp \
"$STANDARD_DMG_NAME"
echo "✓ DMG signed successfully"
else
echo "Skipping DMG signing (not on canonical repo or certs unavailable)"
fi
- name: Notarize DMG Installer
if: github.repository == 'HDFGroup/hdfview' && env.APPLE_CERTS_BASE64 != ''
run: |
echo "Submitting DMG for notarization..."
cd hdfview/target/dist
echo "DMG file: $STANDARD_DMG_NAME"
xcrun notarytool submit "$STANDARD_DMG_NAME" \
--apple-id "$NOTARY_USER" \
--password "$NOTARY_KEY" \
--team-id "$SIGNER" \
--wait \
--timeout 30m \
--output-format json > notarization-response.json
cat notarization-response.json
STATUS=$(cat notarization-response.json | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
SUBMISSION_ID=$(cat notarization-response.json | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)
echo "Notarization status: $STATUS"
echo "Submission ID: $SUBMISSION_ID"
if [ "$STATUS" = "Accepted" ]; then
echo "✓ Notarization successful"
else
echo "✗ Notarization failed with status: $STATUS"
if [ -n "$SUBMISSION_ID" ]; then
xcrun notarytool log "$SUBMISSION_ID" \
--apple-id "$NOTARY_USER" \
--password "$NOTARY_KEY" \
--team-id "$SIGNER" || echo "Failed to fetch log"
fi
exit 1
fi
- name: Staple Notarization to DMG
if: github.repository == 'HDFGroup/hdfview' && env.APPLE_CERTS_BASE64 != ''
run: |
echo "Stapling notarization ticket to DMG..."
cd hdfview/target/dist
for i in 1 2 3 4 5; do
xcrun stapler staple "$STANDARD_DMG_NAME" && break
[ $i -eq 5 ] && exit 1
echo "Staple/validate attempt $i failed; retrying in 30s..."; sleep 30
done
echo "✓ Notarization ticket stapled successfully"
- name: Upload DMG Installer Artifact
uses: actions/upload-artifact@v4
with:
name: dmg-macos-${{ matrix.arch }}-installer
path: hdfview/target/dist/*.dmg
retention-days: 30
if-no-files-found: error