Updates
ci / test (push) Successful in 37s
ci / release (push) Successful in 1m26s

This commit is contained in:
2026-07-03 05:52:11 -04:00
parent e8ee8319eb
commit 2d63ee476a
2 changed files with 88 additions and 10 deletions
+77
View File
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
# Install Go for CI without actions/setup-go (Gitea runners often cannot
# reach github.com/actions/go-versions reliably).
set -euo pipefail
GO_VERSION="${GO_VERSION:-1.24.5}"
go_ok() {
command -v go >/dev/null 2>&1 || return 1
local ver
ver="$(go env GOVERSION 2>/dev/null || go version | awk '{print $3}')"
ver="${ver#go}"
local major minor
major="${ver%%.*}"
minor="${ver#*.}"; minor="${minor%%.*}"
[[ "$major" -gt 1 || ( "$major" -eq 1 && "$minor" -ge 24 ) ]]
}
if go_ok; then
echo "Using existing Go: $(go version)"
exit 0
fi
case "$(uname -m)" in
x86_64) GOARCH=amd64 ;;
aarch64 | arm64) GOARCH=arm64 ;;
*)
echo "unsupported architecture: $(uname -m)" >&2
exit 1
;;
esac
TARBALL="go${GO_VERSION}.linux-${GOARCH}.tar.gz"
URLS=(
"https://go.dev/dl/${TARBALL}"
"https://dl.google.com/go/${TARBALL}"
)
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
downloaded=0
for url in "${URLS[@]}"; do
echo "Downloading Go ${GO_VERSION} from ${url}"
if curl -fsSL --connect-timeout 30 --max-time 600 --retry 5 --retry-delay 10 \
-o "${tmpdir}/${TARBALL}" "${url}"; then
downloaded=1
break
fi
echo "download failed: ${url}" >&2
done
if [[ "$downloaded" -ne 1 ]]; then
echo "could not download Go ${GO_VERSION}" >&2
exit 1
fi
tar -xzf "${tmpdir}/${TARBALL}" -C "${tmpdir}"
toolcache="${RUNNER_TOOL_CACHE:-/opt/hostedtoolcache}"
install_dir="${toolcache}/go/${GO_VERSION}/${GOARCH}"
rm -rf "${install_dir}"
mkdir -p "$(dirname "${install_dir}")"
mv "${tmpdir}/go" "${install_dir}"
bin_dir="${install_dir}/bin"
echo "${bin_dir}" >>"${GITHUB_PATH:-/dev/null}"
{
echo "GOROOT=${install_dir}"
echo "GOTOOLCHAIN=local"
} >>"${GITHUB_ENV:-/dev/null}"
export PATH="${bin_dir}:${PATH}"
export GOROOT="${install_dir}"
export GOTOOLCHAIN=local
echo "Installed $(go version) to ${install_dir}"