31 lines
1.3 KiB
Bash
Executable file
31 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Baut das CLI für alle unterstützten Systeme (→ KONZEPT.md 11, 18).
|
|
#
|
|
# scripts/build-cli.sh 0.2.0 # nach cli/dist/0.2.0/
|
|
# scripts/build-cli.sh 0.2.0 /srv/hugin-downloads # zusätzlich in den Download-Ordner (HUGIN_DOWNLOAD_DIR)
|
|
#
|
|
# Ergebnis: hugin-<os>-<arch>[.exe] und SHA256SUMS. Ohne CGO, also ohne
|
|
# Abhängigkeiten auf dem Zielrechner.
|
|
set -euo pipefail
|
|
|
|
VERSION="${1:?Version angeben, z. B. scripts/build-cli.sh 0.2.0}"
|
|
[[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Version im Format x.y.z"; exit 2; }
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
TARGET="$ROOT/cli/dist/$VERSION"
|
|
rm -rf "$TARGET" && mkdir -p "$TARGET"
|
|
|
|
for platform in darwin/arm64 darwin/amd64 linux/amd64 linux/arm64 windows/amd64; do
|
|
os="${platform%/*}"; arch="${platform#*/}"
|
|
file="hugin-$os-$arch"; [[ "$os" == windows ]] && file+=".exe"
|
|
(cd "$ROOT/cli" && CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \
|
|
go build -trimpath -ldflags "-s -w -X main.Version=$VERSION" -o "$TARGET/$file" ./cmd/hugin)
|
|
echo " $file"
|
|
done
|
|
(cd "$TARGET" && shasum -a 256 hugin-* > SHA256SUMS)
|
|
echo "Gebaut: $TARGET"
|
|
|
|
if [[ -n "${2:-}" ]]; then
|
|
mkdir -p "$2/$VERSION"
|
|
cp "$TARGET"/* "$2/$VERSION/"
|
|
echo "Kopiert nach $2/$VERSION (für die Seite „Programm hugin“)"
|
|
fi
|