36 lines
952 B
Bash
Executable File
36 lines
952 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
version=${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}
|
|
commit=${COMMIT:-$(git rev-parse --short HEAD 2>/dev/null || echo unknown)}
|
|
build_date=${BUILD_DATE:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}
|
|
ldflags="-s -w -X main.version=$version -X main.commit=$commit -X main.date=$build_date"
|
|
|
|
mkdir -p dist
|
|
|
|
for target in \
|
|
linux/amd64 \
|
|
linux/arm64 \
|
|
darwin/amd64 \
|
|
darwin/arm64 \
|
|
windows/amd64 \
|
|
windows/arm64
|
|
do
|
|
goos=${target%/*}
|
|
goarch=${target#*/}
|
|
output="dist/ufile-cli_${goos}_${goarch}"
|
|
if [ "$goos" = windows ]; then
|
|
output="${output}.exe"
|
|
fi
|
|
echo "building $output"
|
|
CGO_ENABLED=0 GOOS=$goos GOARCH=$goarch go build -trimpath -ldflags="$ldflags" -o "$output" ./cmd/ufile-cli
|
|
done
|
|
|
|
if command -v sha256sum >/dev/null 2>&1; then
|
|
(cd dist && sha256sum ufile-cli_*) > dist/checksums.txt
|
|
else
|
|
(cd dist && shasum -a 256 ufile-cli_*) > dist/checksums.txt
|
|
fi
|