From e8421fc3ffa19d25014da8110c2afb50e35192fb Mon Sep 17 00:00:00 2001 From: mixeme Date: Mon, 22 Jun 2026 23:31:05 +0300 Subject: [PATCH] Fix CRLF breakage in Linux build scripts The Linux build host reads these scripts from a shared mount of the Windows working tree, where autocrlf produces CRLF line endings. bash then failed on `set -o pipefail` (trailing CR in the option name), and the version parsed from version.go carried a trailing CR into the Docker tag ("...:0.6.0\r": invalid reference format). - Add .gitattributes forcing LF on *.sh so Windows checkouts stay LF. - Strip CR from the version extraction in all three Linux build scripts. Co-Authored-By: Claude Opus 4.8 --- .gitattributes | 3 +++ scripts/build-linux-docker.sh | 2 +- scripts/build-linux.sh | 2 +- scripts/build-release-linux.sh | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d454146 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Keep shell scripts LF even on Windows checkouts so bash on Linux hosts +# doesn't choke on trailing CRs (e.g. "set: pipefail: invalid parameter name"). +*.sh text eol=lf diff --git a/scripts/build-linux-docker.sh b/scripts/build-linux-docker.sh index 9f267db..ecd4e7d 100644 --- a/scripts/build-linux-docker.sh +++ b/scripts/build-linux-docker.sh @@ -4,7 +4,7 @@ set -euo pipefail # Optional first argument mirrors build-linux.sh. The Docker build still writes # the final artifact into the local dist/ tree, not into the container. The # default includes the application version and target platform. -version="$(sed -n 's/^var Version = "\(.*\)"/\1/p' src/app/version.go)" +version="$(sed -n 's/^var Version = "\(.*\)"/\1/p' src/app/version.go | tr -d '\r')" version="${version:-0.0.0-dev}" tag="gitea.mixdep.ru/mix/gosentry-builder:${version}" output="${1:-dist/linux/gosentry-${version}-linux-amd64}" diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 23b16d3..9c68152 100644 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -3,7 +3,7 @@ set -euo pipefail # Optional first argument lets a developer or CI job choose the output path. The # default includes the application version and target platform. -version="$(sed -n 's/^var Version = "\(.*\)"/\1/p' src/app/version.go)" +version="$(sed -n 's/^var Version = "\(.*\)"/\1/p' src/app/version.go | tr -d '\r')" version="${version:-0.0.0-dev}" output="${1:-dist/linux/gosentry-${version}-linux-amd64}" mkdir -p "$(dirname "$output")" diff --git a/scripts/build-release-linux.sh b/scripts/build-release-linux.sh index b3f8dea..fc3942e 100644 --- a/scripts/build-release-linux.sh +++ b/scripts/build-release-linux.sh @@ -9,7 +9,7 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" repo_root="$(cd "${script_dir}/.." && pwd)" cd "$repo_root" -version="$(sed -n 's/^var Version = "\(.*\)"/\1/p' src/app/version.go)" +version="$(sed -n 's/^var Version = "\(.*\)"/\1/p' src/app/version.go | tr -d '\r')" version="${version:-0.0.0-dev}" tag="gitea.mixdep.ru/mix/gosentry-builder:${version}"