From 316d16e438507353bbae29c8885c00ef2f5f3d4f Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Tue, 29 Sep 2026 15:56:22 -0600 Subject: [PATCH] scripts/helm-docs.sh: detect CPU architecture on every OS The script hardcoded x86_64 on macOS, so Apple Silicon machines downloaded an amd64 binary that fails with "Bad CPU type in executable". On Linux the amd64 branch pointed at a release asset that does not exist, and arm64 hosts report aarch64, which the script never matched. Map uname -m to the helm-docs release asset names for all supported OSes. Amp-Thread-ID: https://ampcode.com/threads/T-01a0e96e-01bb-762e-a752-d2a3103593f0 Co-authored-by: Amp --- scripts/helm-docs.sh | 47 +++++++++++++------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/scripts/helm-docs.sh b/scripts/helm-docs.sh index 09177cd0c..6baa9bcbd 100755 --- a/scripts/helm-docs.sh +++ b/scripts/helm-docs.sh @@ -7,42 +7,23 @@ helmdocsv=1.7.0 bindir=$( cd "${0%/*}" && pwd ) # Change to script dir and set bin dir to this targetbin=$( cd "$bindir"/.. && pwd )/target/bin helmdocsbin=$targetbin/helm-docs-$helmdocsv -os="" -arch="" if [ ! -f "$helmdocsbin" ]; then - case $(uname | tr '[:upper:]' '[:lower:]') in - darwin*) - os=darwin - arch=x86_64 - ;; - linux*) - os=linux - case $(uname -m) in - x86_64) arch=x86_64 ;; - amd64) arch=amd64 ;; - arm) - tmp=$(dpkg --print-architecture) - if echo "$tmp" | grep -q arm64; then - arch=arm64 - elif echo "$tmp" | grep -q armv7; then - arch=armv7 - elif echo "$tmp" | grep -q armv6; then - arch=armv6 - fi - ;; - esac - ;; - msys*) - os=windows - arch=x86_64 - ;; + # Release assets are named helm-docs___.tar.gz, + # e.g. Darwin_arm64, Linux_x86_64, Windows_x86_64 + case $(uname -s) in + Darwin) os=Darwin ;; + Linux) os=Linux ;; + MSYS*|MINGW*|CYGWIN*) os=Windows ;; + *) echo "Unsupported OS: $(uname -s)"; exit 126 ;; + esac + case $(uname -m) in + x86_64|amd64) arch=x86_64 ;; + aarch64|arm64) arch=arm64 ;; + armv7l) arch=armv7 ;; + armv6l) arch=armv6 ;; + *) echo "Unsupported architecture: $(uname -m)"; exit 126 ;; esac - - if [ -z "$os" ]; then - echo "Couldn't find a matching binary" - exit 126 - fi helmdocscurl="https://github.com/norwoodj/helm-docs/releases/download/v$helmdocsv/helm-docs_${helmdocsv}_${os}_${arch}.tar.gz" tmp=$(mktemp -d -t helm-docs.XXX) mkdir -p "$targetbin"