Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C
1.5 KB
Raw Blame
#!/bin/sh
# Writes the What's new sheet's text (App/Onboarding/WhatsNew.m) as an Objective-C header: the section
# of CHANGELOG.md that Release Please wrote for VERSION, as it stands, for App/About/Update.m's parser.
# The sections that came over with the fork are upstream's releases, not this one's, and are left out
# (their heading links to skopevoj/spoti.pw); a build with no section of its own gets an empty string.
# ALLOW_UPSTREAM=1 takes them anyway, for the harness.
#
#   scripts/whats-new.sh 0.22.0 [CHANGELOG.md [OUT]]
#
# With OUT, the header is written there only when it changed, so a build that runs this on every make
# does not compile WhatsNew.m again for nothing.
set -e
version=$1
changelog=${2:-$(dirname "$0")/../CHANGELOG.md}
if [ -n "$3" ]; then
    "$0" "$version" "$changelog" > "$3.tmp"
    if cmp -s "$3.tmp" "$3"; then rm "$3.tmp"; else mv "$3.tmp" "$3"; fi
    exit 0
fi
printf '// Generated by scripts/whats-new.sh from CHANGELOG.md for %s. Do not edit.\n' "$version"
printf 'static NSString *const SGWhatsNewNotes = @""\n'
[ -f "$changelog" ] && awk -v version="$version" -v upstream="${ALLOW_UPSTREAM:-0}" '
    /^## / {
        heading = $0
        sub(/^## \[?/, "", heading)
        inside = index(heading, version "]") == 1 || index(heading, version " ") == 1
        if (inside && upstream != 1 && index($0, "skopevoj/spoti.pw")) inside = 0
        next
    }
    inside {
        gsub(/\\/, "\\\\")
        gsub(/"/, "\\\"")
        printf "    \"%s\\n\"\n", $0
    }
' "$changelog"
printf '    ;\n'