From 36f6413917ec509fa81655c25800f0a0a8c38d40 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Sun, 15 Jun 2025 16:02:45 +0200 Subject: [PATCH] feat(build): UPX compression UPX can compress binaries from 22Mo to 7Mo on Linux / Windows and 14Mo on MacOS. Let's use it to reduce binary size. I don't know why it doesn't work on FreeBSD. --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 77efb5d..104a800 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ BLD_CMD=go build -ldflags="-X 'katenary/generator.Version=$(RELEASE)$(VERSION)'" GOOS=linux GOARCH=amd64 SIGNER=metal3d@gmail.com +UPX_OPTS = +UPX ?= upx $(UPX_OPTS) BUILD_IMAGE=docker.io/golang:$(GOVERSION)-alpine # SHELL=/bin/bash @@ -105,7 +107,7 @@ endif ## Release build -dist: prepare $(BINARIES) $(ASC_BINARIES) +dist: prepare $(BINARIES) upx $(ASC_BINARIES) prepare: pull mkdir -p dist @@ -147,6 +149,13 @@ gpg-sign: dist/%.asc: dist/% gpg --armor --detach-sign --default-key $(SIGNER) $< &>/dev/null || exit 1 + +upx: + $(UPX) dist/katenary-linux-amd64 + $(UPX) dist/katenary-linux-arm64 + $(UPX) dist/katenary.exe + $(UPX) dist/katenary-darwin-amd64 --force-macos + install: build install -Dm755 katenary $(PREFIX)/bin/katenary