diff --git a/.github/workflows/cross-compile.sh b/.github/workflows/cross-compile.sh index ff5b67fc4..cd526223f 100755 --- a/.github/workflows/cross-compile.sh +++ b/.github/workflows/cross-compile.sh @@ -12,7 +12,22 @@ if [[ "$goos" == "android" ]]; then exit; fi # Cgo would then need a C cross compilation setup. Not worth the hassle. if [[ "$goos" == "ios" ]]; then exit; fi -echo "$dist" +# Write all log output to a temporary file instead of to stdout. +# That allows running this script in parallel, while preserving the correct order of the output. +log_file=$(mktemp) + +error_handler() { + cat "$log_file" >&2 + rm "$log_file" + exit 1 +} + +trap 'error_handler' ERR + +echo "$dist" >> "$log_file" out="main-$goos-$goarch" -GOOS=$goos GOARCH=$goarch go build -o $out example/main.go +GOOS=$goos GOARCH=$goarch go build -o $out example/main.go >> "$log_file" 2>&1 rm $out + +cat "$log_file" +rm "$log_file"