diff --git a/dist/phirna-appstore.zip b/dist/phirna-appstore.zip new file mode 100644 index 0000000..e1e4964 Binary files /dev/null and b/dist/phirna-appstore.zip differ diff --git a/scripts/build-appstore-zip.sh b/scripts/build-appstore-zip.sh new file mode 100755 index 0000000..ed175ef --- /dev/null +++ b/scripts/build-appstore-zip.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd "$(dirname "$0")/.." && pwd)" +output_dir="${1:-$repo_root/dist}" +#zip_name="${2:-zima-appstore-$(date +%Y%m%d-%H%M%S).zip}" +zip_name="${2:-phirna-appstore.zip}" + +usage() { + cat </dev/null 2>&1; then + echo "ERROR: 'zip' command not found" + exit 1 +fi + +required_root_files=( + "category-list.json" + "recommend-list.json" + "featured-apps.json" +) + +for file in "${required_root_files[@]}"; do + if [[ ! -f "$repo_root/$file" ]]; then + echo "ERROR: missing required file: $file" + exit 1 + fi +done + +if [[ ! -d "$repo_root/Apps" ]]; then + echo "ERROR: missing required directory: Apps" + exit 1 +fi + +is_git_repo=0 +if git -C "$repo_root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then + is_git_repo=1 +fi + +tmp_dir="$(mktemp -d)" +staging_dir="$tmp_dir/appstore" +cleanup() { + rm -rf "$tmp_dir" +} +trap cleanup EXIT + +mkdir -p "$staging_dir/Apps" + +copy_file() { + local rel="$1" + mkdir -p "$staging_dir/$(dirname "$rel")" + cp "$repo_root/$rel" "$staging_dir/$rel" +} + +if [[ "$is_git_repo" -eq 1 ]]; then + # Build from tracked files only so accidental local files are excluded. + while IFS= read -r rel; do + [[ -z "$rel" ]] && continue + + case "$rel" in + Apps/*|category-list.json|recommend-list.json|featured-apps.json) + if [[ -f "$repo_root/$rel" ]]; then + copy_file "$rel" + fi + ;; + esac + done < <(git -C "$repo_root" ls-files) +else + cp -R "$repo_root/Apps" "$staging_dir/" + for file in "${required_root_files[@]}"; do + copy_file "$file" + done +fi + +# Export compatibility: source uses .yaml, AppStore tooling often expects .yml +while IFS= read -r compose_yaml; do + compose_yml="${compose_yaml%.yaml}.yml" + cp "$compose_yaml" "$compose_yml" + rm -f "$compose_yaml" +done < <(find "$staging_dir/Apps" -type f -name 'docker-compose.yaml' | sort) + +if ! find "$staging_dir/Apps" -type f -name 'docker-compose.yml' | grep -q .; then + echo "ERROR: no docker-compose.yml files found in exported Apps" + exit 1 +fi + +mkdir -p "$output_dir" +zip_path="$(cd "$output_dir" && pwd)/$zip_name" + +( + cd "$staging_dir" + zip -rq "$zip_path" . -x "*.DS_Store" "__MACOSX/*" +) + +if command -v shasum >/dev/null 2>&1; then + checksum="$(shasum -a 256 "$zip_path" | awk '{print $1}')" + echo "ZIP created: $zip_path" + echo "SHA256: $checksum" +else + echo "ZIP created: $zip_path" +fi