#!/bin/sh set -eu ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd) ASSETS="$ROOT/android/store-assets" LISTINGS="$ROOT/android/play-store" if ! command -v identify >/dev/null 2>&1; then echo "ImageMagick identify is required to validate Play Store assets." >&2 exit 1 fi validate_image() { path=$1 expected_width=$2 expected_height=$3 max_bytes=$4 alpha_policy=$5 if [ ! -s "$path" ]; then echo "Missing or empty Play Store asset: $path" >&2 exit 1 fi dimensions=$(identify -format '%wx%h' "$path") if [ "$dimensions" != "${expected_width}x${expected_height}" ]; then echo "Unexpected dimensions for $path: $dimensions" >&2 exit 1 fi bytes=$(stat -c '%s' "$path") if [ "$bytes" -gt "$max_bytes" ]; then echo "Play Store asset exceeds its size limit: $path ($bytes bytes)" >&2 exit 1 fi channels=$(identify -format '%[channels]' "$path") case "$alpha_policy:$channels" in required:*a*) ;; forbidden:*a*) echo "Play Store asset must not contain an alpha channel: $path" >&2 exit 1 ;; forbidden:*) ;; required:*) echo "Play Store asset must contain an alpha channel: $path" >&2 exit 1 ;; esac } extract_section() { file=$1 heading=$2 awk -v heading="$heading" ' $0 == heading {in_section = 1; next} in_section && /^## / {exit} in_section { if (seen || $0 != "") { print seen = 1 } } ' "$file" | sed -e '/^[[:space:]]*$/d' -e '${/^$/d;}' } validate_image "$ASSETS/icon-512.png" 512 512 1048576 required validate_image \ "$ASSETS/feature-graphic-1024x500.png" \ 1024 500 15728640 forbidden screenshot_count=0 for screenshot in "$ASSETS"/screenshots/phone/*.png; do validate_image "$screenshot" 1080 1920 8388608 forbidden screenshot_count=$((screenshot_count + 1)) done if [ "$screenshot_count" -lt 4 ]; then echo "At least four approved phone screenshots are required." >&2 exit 1 fi for listing in "$LISTINGS"/store-listing-*.md; do app_name=$(extract_section "$listing" "## App name") short_description=$(extract_section "$listing" "## Short description") full_description=$(extract_section "$listing" "## Full description") app_name_length=$(printf '%s' "$app_name" | wc -m) short_length=$(printf '%s' "$short_description" | wc -m) full_length=$(printf '%s' "$full_description" | wc -m) if [ "$app_name_length" -gt 30 ]; then echo "App name exceeds 30 characters in $listing." >&2 exit 1 fi if [ "$short_length" -gt 80 ]; then echo "Short description exceeds 80 characters in $listing." >&2 exit 1 fi if [ "$full_length" -gt 4000 ]; then echo "Full description exceeds 4000 characters in $listing." >&2 exit 1 fi done echo "Play Store assets and listing lengths are valid."