#!/bin/sh # install-actionlint.sh — idempotent installer for rhysd/actionlint. # Detects OS+arch, downloads the pinned release tarball to ~/.local/bin/actionlint. # No-op if the binary is already on PATH. On macOS with Homebrew available and # no local binary, suggests `brew install actionlint` as a faster alternative. # # Version pinned after WebFetch verification 2026-04-22. # [VERIFIED: https://github.com/rhysd/actionlint/releases/tag/v1.7.12] # Checksums from upstream checksums.txt (same release page). set -eu ACTIONLINT_VERSION="1.7.12" INSTALL_DIR="${HOME}/.local/bin" BIN="${INSTALL_DIR}/actionlint" if command -v actionlint >/dev/null 2>&1; then printf 'actionlint already on PATH: %s\n' "$(command -v actionlint)" exit 0 fi OS=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH_RAW=$(uname -m) case "${ARCH_RAW}" in x86_64|amd64) ARCH="amd64" ;; arm64|aarch64) ARCH="arm64" ;; *) printf 'unsupported arch: %s\n' "${ARCH_RAW}" >&2; exit 2 ;; esac case "${OS}" in darwin|linux) : ;; *) printf 'unsupported os: %s\n' "${OS}" >&2; exit 2 ;; esac # Homebrew fast-path on macOS. if [ "${OS}" = "darwin" ] && command -v brew >/dev/null 2>&1; then printf 'Homebrew detected. Fast path:\n brew install actionlint\n' printf 'Falling through to tarball install (~/.local/bin) anyway.\n' fi ASSET="actionlint_${ACTIONLINT_VERSION}_${OS}_${ARCH}.tar.gz" URL="https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/${ASSET}" mkdir -p "${INSTALL_DIR}" TMP=$(mktemp -d) trap 'rm -rf "${TMP}"' EXIT INT TERM printf 'downloading %s\n' "${URL}" if command -v curl >/dev/null 2>&1; then curl -fsSL -o "${TMP}/${ASSET}" "${URL}" elif command -v wget >/dev/null 2>&1; then wget -qO "${TMP}/${ASSET}" "${URL}" else printf 'neither curl nor wget is installed\n' >&2 exit 2 fi tar -xzf "${TMP}/${ASSET}" -C "${TMP}" actionlint install -m 0755 "${TMP}/actionlint" "${BIN}" printf 'installed: %s\n' "${BIN}" case ":${PATH}:" in *:"${INSTALL_DIR}":*) : ;; *) printf 'note: %s is not on PATH — add it to your shell profile.\n' "${INSTALL_DIR}" ;; esac