The runner defaults to sh, but the version and release steps use bash syntax. Downloads from GitHub now retry on any error (connection resets broke run #2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
1.0 KiB
Bash
Executable File
27 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Download the pinned upstream ttyd static binary and verify it against the
|
|
# vendored SHA256SUMS. Usage: scripts/fetch-ttyd.sh OUTPUT [ARCH]
|
|
set -euo pipefail
|
|
|
|
out=${1:?usage: fetch-ttyd.sh OUTPUT [ARCH]}
|
|
arch=${2:-x86_64}
|
|
here=$(cd "$(dirname "$0")/.." && pwd)
|
|
version=$(cat "$here/vendor/ttyd/VERSION")
|
|
asset="ttyd.$arch"
|
|
expected=$(awk -v a="$asset" '$2 == a { print $1 }' "$here/vendor/ttyd/SHA256SUMS")
|
|
[ -n "$expected" ] || { echo "fetch-ttyd: no checksum for $asset" >&2; exit 1; }
|
|
|
|
if [ -f "$out" ] && echo "$expected $out" | sha256sum -c --status -; then
|
|
exit 0
|
|
fi
|
|
|
|
mkdir -p "$(dirname "$out")"
|
|
tmp=$(mktemp "$out.XXXXXX")
|
|
trap 'rm -f "$tmp"' EXIT
|
|
curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors -o "$tmp" "https://github.com/tsl0922/ttyd/releases/download/$version/$asset"
|
|
echo "$expected $tmp" | sha256sum -c --status - || { echo "fetch-ttyd: checksum mismatch for $asset $version" >&2; exit 1; }
|
|
chmod 0755 "$tmp"
|
|
mv -f "$tmp" "$out"
|
|
trap - EXIT
|
|
echo "fetch-ttyd: $asset $version verified"
|