forked from jack9966qk/TJAAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease-data.sh
More file actions
executable file
·94 lines (78 loc) · 3.42 KB
/
Copy pathrelease-data.sh
File metadata and controls
executable file
·94 lines (78 loc) · 3.42 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
#!/bin/bash
set -e
# Package format version. Increment this when the zip structure changes in a
# breaking way (e.g. new required files, renamed paths). The app fetches the
# tag for the format version it supports, so old app versions keep working
# against their own tag when the format changes.
FORMAT_VERSION=1
# Fixed tag per format version. Must not match the app version tag pattern (v*)
# so that app release --generate-notes is not affected.
# Marked as prerelease so GitHub skips it when auto-generating app release changelogs.
TAG="data-v${FORMAT_VERSION}-latest"
ARCHIVE="ese-data.zip"
# Check if gh is installed
if ! command -v gh &> /dev/null; then
echo "Error: GitHub CLI (gh) is not installed."
exit 1
fi
# Check if zip is installed
if ! command -v zip &> /dev/null; then
echo "Error: zip is not installed."
exit 1
fi
# Verify data is present
if [ ! -d "public/ese" ] || [ -z "$(ls -A public/ese)" ]; then
echo "Error: public/ese is missing or empty. Run 'npm run prepare-data' first."
exit 1
fi
if [ ! -f "public/ese_index.json" ]; then
echo "Error: public/ese_index.json is missing. Run 'npm run build-data' first."
exit 1
fi
if [ ! -f "data/song_mapping.json" ]; then
echo "Error: data/song_mapping.json is missing."
exit 1
fi
echo "Packaging ESE data..."
rm -f "$ARCHIVE"
# Write a manifest so the app can check format compatibility before consuming
# the full archive. Kept at the zip root as data-manifest.json.
# Using a fixed path ensures the in-zip name is always "data-manifest.json"
# when added with -j (junk paths).
MANIFEST_TMP="/tmp/data-manifest.json"
printf '{"formatVersion":%d}\n' "$FORMAT_VERSION" > "$MANIFEST_TMP"
# Package files so paths inside the zip match the app's fetch URLs:
# ese/<category>/<song>/<file>.tja
# ese_index.json
# data/song_mapping.json
cd public && zip -r -q "../$ARCHIVE" ese/ ese_index.json && cd ..
zip -q "$ARCHIVE" data/song_mapping.json
# Add manifest at zip root (-j strips the /tmp/ prefix)
zip -j -q "$ARCHIVE" "$MANIFEST_TMP"
rm -f "$MANIFEST_TMP"
echo "Archive size: $(du -sh "$ARCHIVE" | cut -f1)"
# Delete existing data release if present (we reuse the fixed tag)
echo "Updating GitHub release '$TAG'..."
gh release delete "$TAG" --yes 2>/dev/null || true
# Create the data release as a prerelease so it is excluded from app changelog generation
gh release create "$TAG" "$ARCHIVE" \
--title "ESE Data Package" \
--notes "ESE chart data package for offline support (format version $FORMAT_VERSION)." \
--prerelease
echo "ESE data package uploaded successfully!"
rm -f "$ARCHIVE"
# Update the format-version pointer release so the app can discover the latest
# format version without knowing it in advance. The app fetches data-pointer's
# data-manifest.json, compares formatVersion with what it supports, and can
# prompt the user to update if the current format is newer than it understands.
POINTER_TAG="data-pointer"
MANIFEST_TMP="/tmp/data-manifest.json"
printf '{"formatVersion":%d}\n' "$FORMAT_VERSION" > "$MANIFEST_TMP"
echo "Updating format-version pointer release '$POINTER_TAG'..."
gh release delete "$POINTER_TAG" --yes 2>/dev/null || true
gh release create "$POINTER_TAG" "$MANIFEST_TMP" \
--title "ESE Data Package (latest format pointer)" \
--notes "Pointer release that contains only the latest format version (v$FORMAT_VERSION) in \`data-manifest.json\`." \
--prerelease
rm -f "$MANIFEST_TMP"
echo "Format-version pointer updated."