Files
go-lint/ops/build.sh
2026-10-14 20:50:52 -07:00

38 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env sh
set -e
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
cd "$SCRIPT_DIR/.." # .custom-gcl.yaml is only discovered in the current directory
BIN="bin/golint"
STAMP="bin/.golint.stamp"
# Everything that changes the compiled binary: the linter sources, and the build
# config that pins the golangci-lint version the plugin links against. testdata
# is excluded -- fixtures are not compiled into the binary.
current_stamp() {
{
find . -type f ! -path '*/testdata/*' | sort | xargs shasum -a 256
shasum -a 256 .custom-gcl.yaml
} | shasum -a 256 | cut -d' ' -f1
}
if [ "$1" = "--if-needed" ] &&
[ -x "$BIN" ] &&
[ -f "$STAMP" ] &&
[ "$(cat "$STAMP")" = "$(current_stamp)" ]; then
exit 0
fi
if ! [ -x "$(command -v golangci-lint)" ]; then
echo "golangci-lint is not installed. Please install it from https://golangci-lint.run/welcome/install/"
exit 1
fi
echo "Building golint (golangci-lint + custom linters)..."
golangci-lint custom
current_stamp > "$STAMP"
echo "Done: $SCRIPT_DIR/$BIN"