@@ -6,12 +6,19 @@ set -euo pipefail
66readonly GITHUB_OWNER=" rhysd"
77readonly GITHUB_REPO=" actionlint"
88readonly TOOL_NAME=" actionlint"
9- readonly INSTALL_SCRIPT_URL=" https://raw.githubusercontent.com/${GITHUB_OWNER} /${GITHUB_REPO} /main/scripts/download-actionlint.bash"
10-
11- # Configuration (can be overridden by env)
9+ # Installer script SHA provided via INSTALLER_SHA env var from Taskfile
10+ # To update: change the SHA in github.Taskfile.yml GITHUB_INSTALLER_SHA.actionlint
11+ readonly INSTALL_SCRIPT_SHA=" ${INSTALLER_SHA:? INSTALLER_SHA env var is required — set in Taskfile} "
12+ [[ " ${INSTALL_SCRIPT_SHA} " =~ ^[0-9a-fA-F]{40}$ ]] || {
13+ echo " X Error: INSTALLER_SHA must be a full 40-character hexadecimal commit SHA" >&2
14+ exit 1
15+ }
16+ readonly INSTALL_SCRIPT_URL=" https://raw.githubusercontent.com/${GITHUB_OWNER} /${GITHUB_REPO} /${INSTALL_SCRIPT_SHA} /scripts/download-actionlint.bash"
1217VERSION=" ${1:- ${VERSION:- latest} } "
1318INSTALL_DIR=" ${2:- ${INSTALL_DIR:- } } "
1419
20+ tempDir=" "
21+
1522# Logging helper
1623log () {
1724 echo " -> $* " >&2
@@ -23,6 +30,13 @@ die() {
2330 exit " ${2:- 1} "
2431}
2532
33+ cleanup () {
34+ if [[ -n " ${tempDir} " && -d " ${tempDir} " ]]; then
35+ rm -rf " ${tempDir} "
36+ fi
37+ }
38+ trap cleanup EXIT INT TERM
39+
2640# Help message
2741usage () {
2842 cat << EOF
@@ -32,16 +46,20 @@ Positional arguments:
3246 VERSION Version to install (default: latest)
3347 INSTALL_DIR Custom install directory
3448
35- Environment variables:
49+ Environment variables (required):
50+ INSTALLER_SHA Full 40-char hex commit SHA for the installer script (set by Taskfile)
51+
52+ Environment variables (optional):
3653 VERSION Desired version (default: latest)
3754 INSTALL_DIR Install directory override
3855 GITHUB_TOKEN GitHub token for API authentication
3956
4057Examples:
41- $0 # Install latest
42- $0 1.2.3 # Install 1.2.3
43- $0 1.2.3 ~/.local/bin # Install 1.2.3 to ~/.local/bin
44- VERSION=v1.2.3 $0 # Install 1.2.3 via env
58+ INSTALLER_SHA=<sha> $0 # Install latest
59+ INSTALLER_SHA=<sha> $0 1.2.3 # Install 1.2.3
60+ INSTALLER_SHA=<sha> $0 1.2.3 ~/.local/bin # Install 1.2.3 to ~/.local/bin
61+
62+ Note: Normally invoked via Taskfile (e.g., task install:actionlint), which sets INSTALLER_SHA automatically.
4563EOF
4664}
4765
84102 ghAuthHeader=()
85103fi
86104
87- # Execute remote installation script
88- log " Fetching and executing official installation script"
89- if ! curl " ${ghAuthHeader[@]} " -fsSL " ${INSTALL_SCRIPT_URL} " | /bin/bash -s -- " ${VERSION} " " ${INSTALL_DIR} " ; then
105+ # Download installation script to temp file (avoid piping curl to shell)
106+ tempDir=" $( mktemp -d) " || die " Failed to create temp directory"
107+ INSTALL_SCRIPT=" ${tempDir} /download-actionlint.bash"
108+ log " Downloading official installation script (pinned to ${INSTALL_SCRIPT_SHA} )"
109+ if ! curl " ${ghAuthHeader[@]} " -fsSL " ${INSTALL_SCRIPT_URL} " -o " ${INSTALL_SCRIPT} " ; then
110+ die " Failed to download installation script. Check network connection."
111+ fi
112+ chmod +x " ${INSTALL_SCRIPT} "
113+
114+ # Execute downloaded script
115+ log " Executing installation script"
116+ if ! /bin/bash " ${INSTALL_SCRIPT} " " ${VERSION} " " ${INSTALL_DIR} " ; then
90117 die " Installation failed. Check version or network connection."
91118fi
92119
0 commit comments