From 0dfa377e085ba8c425042e8bba2cdc6f168d20a7 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Mon, 27 Feb 2023 21:25:07 +0700 Subject: [PATCH] Add freebsd to goreleaser config While at it, fixed the hook upx script to run per file, and ignore binaries which are not supported. --- .goreleaser.yaml | 7 ++++++- scripts/upx.sh | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index de268bc..f010ff9 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -11,6 +11,7 @@ builds: - -s -w goos: - linux + - freebsd - windows goarch: - 386 @@ -26,7 +27,11 @@ builds: - softfloat main: ./cmd/ctrld hooks: - post: /bin/sh ./scripts/upx.sh + post: /bin/sh ./scripts/upx.sh {{ .Path }} + ignore: + - goos: freebsd + goarch: arm + goarm: 5 archives: - format_overrides: - goos: windows diff --git a/scripts/upx.sh b/scripts/upx.sh index 55c60e7..5d366eb 100755 --- a/scripts/upx.sh +++ b/scripts/upx.sh @@ -2,6 +2,22 @@ set -ex -for dist_dir in ./dist/ctrld*; do - upx --brute "${dist_dir}/ctrld" -done +binary=$1 + +if [ -z "$binary" ]; then + echo >&2 "Usage: $0 " + exit 1 +fi + +case "$binary" in + *_freebsd_*) + echo >&2 "upx does not work with freebsd binary yet" + exit 0 + ;; + *_windows_arm*) + echo >&2 "upx does not work with windows arm/arm64 binary yet" + exit 0 + ;; +esac + +upx -- "$binary"