#!/bin/bash # Usage: tools/set-release.sh VERSION SHA256 # Points the download page at downloads/Textley-VERSION.dmg and shows its checksum. set -euo pipefail version="${1:?Usage: tools/set-release.sh VERSION SHA256}" sha="${2:?Usage: tools/set-release.sh VERSION SHA256}" [[ "$sha" =~ ^[0-9a-f]{64}$ ]] || { echo 'Pass the 64-character SHA-256 of the DMG.' >&2; exit 1; } cd "$(dirname "$0")/.." [[ -f "downloads/Textley-$version.dmg" ]] || { echo "Stage downloads/Textley-$version.dmg first." >&2; exit 1; } [[ "$(shasum -a 256 "downloads/Textley-$version.dmg" | cut -d' ' -f1)" == "$sha" ]] || { echo 'Checksum does not match the staged DMG.' >&2; exit 1; } perl -0pi -e "s/Textley-\d+\.\d+\.\d+\.dmg/Textley-$version.dmg/g; s/Version \d+\.\d+\.\d+/Version $version/g; s/()(?:TEXTLEY_DMG_SHA256|[0-9a-f]{64})(<\/code>)/\${1}$sha\${2}/" download/index.html perl -0pi -e "s/Version \d+\.\d+\.\d+/Version $version/" index.html grep -n "Textley-$version.dmg\|$sha" download/index.html