Skip to content

Commit 09e488f

Browse files
scripts/helm-docs.sh: detect CPU architecture on every OS (#952)
`scripts/helm-docs.sh` hardcoded `arch=x86_64` on macOS, so on Apple Silicon it downloads an amd64 binary and fails: ``` target/bin/helm-docs-1.7.0: Bad CPU type in executable ``` Two more latent bugs in the same block: the Linux `amd64` branch pointed at `helm-docs_1.7.0_linux_amd64.tar.gz`, which is not a published asset (they are `x86_64`), and Linux arm64 hosts report `aarch64` from `uname -m`, which the `arm)` branch never matched. This replaces the per-OS blocks with one `uname -s` case for the OS and one `uname -m` case for the architecture, mapped to the [release asset names](https://github.com/norwoodj/helm-docs/releases/tag/v1.7.0) (`Darwin_arm64`, `Linux_x86_64`, ...). Unsupported combinations exit 126 with the offending value instead of a generic message. The pinned version stays at 1.7.0 so generated READMEs do not churn. ## Test plan - On an M-series Mac: `rm -rf target && ./scripts/helm-docs.sh` downloads `Mach-O 64-bit executable arm64` and regenerates all four chart READMEs with no diff (the `AGENTS.md` check). - `curl -I` confirms `Darwin_x86_64`, `Darwin_arm64`, `Linux_x86_64`, `Linux_arm64` assets exist for v1.7.0 and `linux_amd64` returns 404. Co-authored-by: Amp <amp@ampcode.com>
1 parent 1248d79 commit 09e488f

1 file changed

Lines changed: 14 additions & 33 deletions

File tree

‎scripts/helm-docs.sh‎

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,23 @@ helmdocsv=1.7.0
77
bindir=$( cd "${0%/*}" && pwd ) # Change to script dir and set bin dir to this
88
targetbin=$( cd "$bindir"/.. && pwd )/target/bin
99
helmdocsbin=$targetbin/helm-docs-$helmdocsv
10-
os=""
11-
arch=""
1210

1311
if [ ! -f "$helmdocsbin" ]; then
14-
case $(uname | tr '[:upper:]' '[:lower:]') in
15-
darwin*)
16-
os=darwin
17-
arch=x86_64
18-
;;
19-
linux*)
20-
os=linux
21-
case $(uname -m) in
22-
x86_64) arch=x86_64 ;;
23-
amd64) arch=amd64 ;;
24-
arm)
25-
tmp=$(dpkg --print-architecture)
26-
if echo "$tmp" | grep -q arm64; then
27-
arch=arm64
28-
elif echo "$tmp" | grep -q armv7; then
29-
arch=armv7
30-
elif echo "$tmp" | grep -q armv6; then
31-
arch=armv6
32-
fi
33-
;;
34-
esac
35-
;;
36-
msys*)
37-
os=windows
38-
arch=x86_64
39-
;;
12+
# Release assets are named helm-docs_<version>_<OS>_<arch>.tar.gz,
13+
# e.g. Darwin_arm64, Linux_x86_64, Windows_x86_64
14+
case $(uname -s) in
15+
Darwin) os=Darwin ;;
16+
Linux) os=Linux ;;
17+
MSYS*|MINGW*|CYGWIN*) os=Windows ;;
18+
*) echo "Unsupported OS: $(uname -s)"; exit 126 ;;
19+
esac
20+
case $(uname -m) in
21+
x86_64|amd64) arch=x86_64 ;;
22+
aarch64|arm64) arch=arm64 ;;
23+
armv7l) arch=armv7 ;;
24+
armv6l) arch=armv6 ;;
25+
*) echo "Unsupported architecture: $(uname -m)"; exit 126 ;;
4026
esac
41-
42-
if [ -z "$os" ]; then
43-
echo "Couldn't find a matching binary"
44-
exit 126
45-
fi
4627
helmdocscurl="https://github.com/norwoodj/helm-docs/releases/download/v$helmdocsv/helm-docs_${helmdocsv}_${os}_${arch}.tar.gz"
4728
tmp=$(mktemp -d -t helm-docs.XXX)
4829
mkdir -p "$targetbin"

0 commit comments

Comments
 (0)