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