e8421fc3ff
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 <noreply@anthropic.com>
34 lines
1.3 KiB
Bash
34 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
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 | 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}"
|
|
docker_user_args=()
|
|
if command -v id >/dev/null 2>&1; then
|
|
docker_user_args=(--user "$(id -u):$(id -g)")
|
|
fi
|
|
|
|
# Dockerfile contains the native packages required by Fyne. Keeping that
|
|
# environment in Docker makes Linux builds repeatable from Windows hosts and CI.
|
|
docker build -f Dockerfile -t "$tag" .
|
|
|
|
mkdir -p "$(dirname "$output")"
|
|
docker run --rm \
|
|
"${docker_user_args[@]}" \
|
|
-e "VERSION=${version}" \
|
|
-e "OUTPUT=${output}" \
|
|
-e "GOCACHE=/tmp/go-build-cache" \
|
|
-v "$(pwd):/src" \
|
|
-w /src \
|
|
"$tag" \
|
|
bash -c 'CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildvcs=false -trimpath -ldflags "-s -w -X gitea.mixdep.ru/mix/gosentry/src/app.Version=${VERSION}" -o "${OUTPUT}" ./cmd/gosentry'
|
|
|
|
# Icons are embedded in the Go binary, so there is no assets directory to copy
|
|
# after extracting the Linux executable.
|
|
echo "Built $output"
|