Files
devplacepy/nodes/client/build.sh
T
retoor 6f80a820da
DevPlace CI / test (push) Failing after 3m13s
Zo doen wijdat in oost
2026-10-16 07:20:44 +02:00

55 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
set -eu
here=$(cd "$(dirname "$0")" && pwd)
out=${1:-./dist}
version=${VERSION:-$(git -C "$here" describe --tags --always --dirty 2>/dev/null || echo dev)}
targets="linux/amd64 linux/arm64 darwin/arm64 darwin/amd64 windows/amd64"
mkdir -p "$out"
out=$(cd "$out" && pwd)
manifest="$out/manifest.json"
rm -f "$manifest"
hash_of() {
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$1" | cut -d' ' -f1
else
shasum -a 256 "$1" | cut -d' ' -f1
fi
}
size_of() {
wc -c <"$1" | tr -d ' '
}
printf '[\n' >"$manifest"
first=1
for target in $targets; do
goos=${target%/*}
goarch=${target#*/}
name="devplace-node-$goos-$goarch"
if [ "$goos" = "windows" ]; then
name="$name.exe"
fi
(cd "$here" && CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" go build -trimpath -ldflags "-s -w -X main.Version=$version" -o "$out/$name" .)
if [ "$first" -eq 0 ]; then
printf ',\n' >>"$manifest"
fi
first=0
printf ' {"name": "%s", "os": "%s", "arch": "%s", "sha256": "%s", "size": %s, "version": "%s"}' \
"$name" "$goos" "$goarch" "$(hash_of "$out/$name")" "$(size_of "$out/$name")" "$version" >>"$manifest"
done
printf '\n]\n' >>"$manifest"
for target in $targets; do
goos=${target%/*}
goarch=${target#*/}
name="devplace-node-$goos-$goarch"
if [ "$goos" = "windows" ]; then
name="$name.exe"
fi
echo "$out/$name"
done
echo "$manifest"