Repository navigation
Expand file tree
/
Copy pathexport-release.sh
More file actions
executable file
·463 lines (366 loc) · 10.8 KB
/
Copy pathexport-release.sh
File metadata and controls
executable file
·463 lines (366 loc) · 10.8 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
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
#!/usr/bin/env bash
set -euo pipefail
# ============================================================
# MPAS Configuration Studio
# Release Export Utility
#
# Creates portable release archives from the CURRENT working
# tree while excluding Git internals, development artifacts,
# caches, and seven intentionally unhosted MPCT mesh products.
# ============================================================
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$REPO_ROOT"
EXPECTED_BRANCH="main"
echo "============================================================"
echo " MPAS CONFIGURATION STUDIO RELEASE EXPORT"
echo "============================================================"
echo
echo "1. Verify repository"
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "[FAIL] Not inside a Git repository"
exit 1
fi
CURRENT_BRANCH="$(git branch --show-current)"
echo "Branch: $CURRENT_BRANCH"
if [ "$CURRENT_BRANCH" != "$EXPECTED_BRANCH" ]; then
echo
echo "[FAIL] Expected branch:"
echo " $EXPECTED_BRANCH"
echo
echo "Current branch:"
echo " $CURRENT_BRANCH"
exit 1
fi
echo "[PASS] correct release-development branch"
echo
echo "2. Determine release identity"
if [ ! -f package.json ]; then
echo "[FAIL] package.json is missing"
exit 1
fi
VERSION="$(
python3 - <<'PY'
import json
with open("package.json", "r", encoding="utf-8") as handle:
data = json.load(handle)
version = data.get("version")
if not version:
raise SystemExit("package.json contains no version")
print(version)
PY
)"
VERSION_TAG="V${VERSION}"
if [ "$VERSION_TAG" != "V1.0.0" ]; then
echo "[FAIL] Expected public release V1.0.0, got $VERSION_TAG"
exit 1
fi
PACKAGE_NAME="MPAS-Configuration-Studio-${VERSION_TAG}"
echo "Version : $VERSION_TAG"
echo "Package : $PACKAGE_NAME"
echo
echo "3. Verify centralized application identity"
APP_VERSION="$(
python3 - <<'PY'
from pathlib import Path
import re
text = Path("src/core/app-version.js").read_text(
encoding="utf-8"
)
match = re.search(
r"MPAS_CONFIG_STUDIO_VERSION\s*=\s*'([^']+)'",
text
)
if not match:
raise SystemExit(
"Unable to determine application version"
)
print(match.group(1))
PY
)"
echo "Application identity: $APP_VERSION"
if [ "$APP_VERSION" != "$VERSION_TAG" ]; then
echo "[FAIL] Application version and package version disagree"
exit 1
fi
echo "[PASS] public export identity fixed at $VERSION_TAG"
echo
echo "4. Record repository state"
HEAD_SHA="$(git rev-parse HEAD)"
HEAD_SHORT="$(git rev-parse --short HEAD)"
echo "HEAD: $HEAD_SHA"
if [ -n "$(git status --porcelain)" ]; then
TREE_STATE="modified"
echo "[INFO] working tree contains uncommitted changes"
else
TREE_STATE="clean"
echo "[PASS] working tree clean"
fi
echo
echo "5. Prepare export directory"
EXPORT_ROOT="$REPO_ROOT/exports"
STAGING_ROOT="$EXPORT_ROOT/.staging"
PACKAGE_DIR="$STAGING_ROOT/$PACKAGE_NAME"
rm -rf "$STAGING_ROOT"
mkdir -p \
"$PACKAGE_DIR" \
"$EXPORT_ROOT"
echo "[PASS] staging directory created"
echo
echo "6. Copy portable working tree"
rsync -a \
--exclude='.git/' \
--exclude='exports/' \
--exclude='.DS_Store' \
--exclude='Thumbs.db' \
--exclude='__pycache__/' \
--exclude='*.pyc' \
--exclude='*.pyo' \
--exclude='*.zip' \
--exclude='*.tar' \
--exclude='*.tar.gz' \
--exclude='*.tar.xz' \
--exclude='*.tgz' \
--exclude='*.swp' \
--exclude='*.swo' \
--exclude='*~' \
--exclude='.idea/' \
--exclude='.vscode/' \
--exclude='.pytest_cache/' \
--exclude='node_modules/' \
--exclude='coverage/' \
--exclude='dist/' \
--exclude='build/' \
--exclude='data/runtime/official-mesh-visualizations/mpct-stage/x1.10485762/' \
--exclude='data/runtime/official-mesh-visualizations/mpct-stage/x1.23592962/' \
--exclude='data/runtime/official-mesh-visualizations/mpct-stage/x1.36864002/' \
--exclude='data/runtime/official-mesh-visualizations/mpct-stage/x1.4096002/' \
--exclude='data/runtime/official-mesh-visualizations/mpct-stage/x1.41943042/' \
--exclude='data/runtime/official-mesh-visualizations/mpct-stage/x1.5898242/' \
--exclude='data/runtime/official-mesh-visualizations/mpct-stage/x1.65536002/' \
"$REPO_ROOT/" \
"$PACKAGE_DIR/"
echo "[PASS] portable source tree copied"
echo
echo "7. Write export provenance"
cat > "$PACKAGE_DIR/EXPORT_PROVENANCE.txt" <<PROVENANCE
MPAS Configuration Studio
Release Export Provenance
====================================
Package:
$PACKAGE_NAME
Application version:
$VERSION_TAG
Git branch:
$CURRENT_BRANCH
Git commit:
$HEAD_SHA
Git short commit:
$HEAD_SHORT
Working-tree state at export:
$TREE_STATE
Exported:
$(date -u '+%Y-%m-%dT%H:%M:%SZ')
Repository:
https://github.com/HathewayWill/MPASConfigurationStudio
Scientific scope:
MPAS-Atmosphere, MPAS-Ocean, MPAS-Seaice, MPAS-Land-Ice / MALI
Supported cores:
init_atmosphere
atmosphere
ocean
seaice
landice
Configuration authorities:
MPAS-Model 8.4.2
E3SM 3.0.2 (Ocean, Seaice, MALI)
Official mesh-source authority:
MPAS-Atmosphere 8.4.1
Mesh preview runtime:
17 Atmosphere exact-cell previews and 19 Ocean, Seaice, and MALI native previews included.
Seven dense Atmosphere meshes remain download-only. Native NetCDF inputs are not bundled.
PROVENANCE
echo "[PASS] export provenance written"
echo
echo "8. Record Git status"
{
echo "MPAS Configuration Studio"
echo "Export Git Status"
echo "====================================="
echo
git status
echo
echo "Commit:"
git log -1 \
--format='Commit: %H%nAuthor: %an <%ae>%nDate: %ad%nSubject: %s' \
--date=iso
} > "$PACKAGE_DIR/EXPORT_GIT_STATUS.txt"
echo "[PASS] Git status written"
echo
echo "9. Generate package manifest"
(
cd "$PACKAGE_DIR"
find . \
-type f \
! -name 'FILE_MANIFEST_SHA256.txt' \
-print0 |
sort -z |
xargs -0 sha256sum \
> FILE_MANIFEST_SHA256.txt
)
FILE_COUNT="$(
find "$PACKAGE_DIR" \
-type f |
wc -l
)"
echo "Files exported: $FILE_COUNT"
echo "[PASS] SHA-256 file manifest generated"
echo
echo "10. Verify important release files"
REQUIRED_FILES=(
"README.md"
"LICENSE.md"
"package.json"
"index.html"
"launch-local.sh"
"launch-local.command"
"launch-local.bat"
"launch-local-server.py"
"src/core/app-version.js"
"docs/USER_GUIDE.md"
)
for required in "${REQUIRED_FILES[@]}"; do
if [ ! -f "$PACKAGE_DIR/$required" ]; then
echo "[FAIL] required release file missing:"
echo " $required"
exit 1
fi
done
echo "[PASS] required release files present"
echo
echo "11. Verify excluded content"
if [ -e "$PACKAGE_DIR/.git" ]; then
echo "[FAIL] .git was included in export"
exit 1
fi
# A release must contain the preview indexes promised by its catalogs.
# This is a packaging presence check, not scientific geometry validation.
python3 - "$PACKAGE_DIR" <<'PY_CHECK_PREVIEWS'
import json, sys
from pathlib import Path
root = Path(sys.argv[1]) / 'data/runtime'
base = root / 'official-mesh-visualizations'
omitted = set(['x1.10485762', 'x1.23592962', 'x1.36864002', 'x1.4096002', 'x1.41943042', 'x1.5898242', 'x1.65536002'])
for mesh in omitted:
if (base / 'mpct-stage' / mesh).exists():
raise SystemExit('[FAIL] Unexpected download-only payload: ' + mesh)
paths = [base / m['true_cell_tiles'] for m in json.loads((base / 'official-mesh-visualization-catalog.json').read_text())['meshes'] if m['id'] not in omitted]
for component in ('ocean', 'seaice', 'landice'):
base = root / (component + '-mesh-visualizations')
paths.extend(base / m['mesh_id'] / m['index'] for m in json.loads((base / (component + '-preview-catalog.json')).read_text())['meshes'])
if len(paths) != 36:
raise SystemExit('[FAIL] Expected 36 hosted preview indexes')
missing = [str(p) for p in paths if not p.is_file()]
if missing:
raise SystemExit('[FAIL] Missing preview indexes:\n' + '\n'.join(missing))
# Check the local binary payloads by path and recorded length. No model simulation is performed.
checked = 0
for index in paths:
if index.name != 'index.json':
continue
data = json.loads(index.read_text())
tiles = data.get('tiles', [])
if isinstance(tiles, dict):
tiles = list(tiles.values())
if len(tiles) != data.get('tile_count') or not tiles:
raise SystemExit('[FAIL] Invalid tile inventory: ' + str(index))
for tile in tiles:
relative = tile.get('binary_path') or tile.get('path')
if not relative or not relative.endswith('.mpct'):
raise SystemExit('[FAIL] Invalid MPCT tile path in ' + str(index))
payload = index.parent / relative
if not payload.is_file():
raise SystemExit('[FAIL] Missing MPCT tile: ' + str(payload))
if isinstance(tile.get('bytes'), int) and payload.stat().st_size != tile['bytes']:
raise SystemExit('[FAIL] MPCT tile size mismatch: ' + str(payload))
checked += 1
print(f'[PASS] 36 hosted preview indexes and {checked} binary tiles present; seven download-only products excluded')
PY_CHECK_PREVIEWS
echo "[PASS] Git metadata excluded"
echo
echo "12. Create tar.gz archive"
TAR_FILE="$EXPORT_ROOT/${PACKAGE_NAME}.tar.gz"
rm -f "$TAR_FILE"
tar \
-C "$STAGING_ROOT" \
-czf "$TAR_FILE" \
"$PACKAGE_NAME"
echo "[PASS] created:"
echo " $TAR_FILE"
echo
echo "13. Create ZIP archive"
ZIP_FILE="$EXPORT_ROOT/${PACKAGE_NAME}.zip"
rm -f "$ZIP_FILE"
(
cd "$STAGING_ROOT"
zip \
-q \
-r \
"$ZIP_FILE" \
"$PACKAGE_NAME"
)
echo "[PASS] created:"
echo " $ZIP_FILE"
echo
echo "14. Generate archive checksums"
(
cd "$EXPORT_ROOT"
sha256sum \
"$(basename "$TAR_FILE")" \
"$(basename "$ZIP_FILE")" \
> "${PACKAGE_NAME}-SHA256SUMS.txt"
)
echo "[PASS] archive checksums generated"
echo
echo "15. Verify archives"
tar -tzf "$TAR_FILE" >/dev/null
unzip -tq "$ZIP_FILE" >/dev/null
echo "[PASS] tar.gz archive verified"
echo "[PASS] ZIP archive verified"
echo
echo "16. Archive sizes"
du -h \
"$TAR_FILE" \
"$ZIP_FILE" \
"$EXPORT_ROOT/${PACKAGE_NAME}-SHA256SUMS.txt"
echo
echo "17. Remove temporary staging tree"
rm -rf "$STAGING_ROOT"
echo "[PASS] staging directory removed"
echo
echo "============================================================"
echo " RELEASE EXPORT COMPLETE"
echo "============================================================"
echo
echo "Package:"
echo " $PACKAGE_NAME"
echo
echo "Source commit:"
echo " $HEAD_SHA"
echo
echo "Working-tree state:"
echo " $TREE_STATE"
echo
echo "Archives:"
echo " $TAR_FILE"
echo " $ZIP_FILE"
echo
echo "Checksums:"
echo " $EXPORT_ROOT/${PACKAGE_NAME}-SHA256SUMS.txt"
echo
echo "Files exported:"
echo " $FILE_COUNT"
echo
echo "Full MPCT runtime:"
echo " EXCLUDED"
echo
echo "============================================================"