Skip to content

Commit 5fd1715

Browse files
committed
chore: optimize binary size with UPX compression (14MB→3-5MB)
- Add UPX compression to GitHub Actions release workflow - Add build-release target in Makefile for local optimized builds - Add -trimpath flag to remove filesystem paths from binary - Bump version to 0.18.2
1 parent 6e838fd commit 5fd1715

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@ jobs:
3939
GOARCH: ${{ matrix.arch }}
4040
CGO_ENABLED: '0'
4141
run: |
42-
go build -ldflags="-s -w" -o openboot-${{ matrix.os }}-${{ matrix.arch }} ./cmd/openboot
42+
go build -ldflags="-s -w" -trimpath -o openboot-${{ matrix.os }}-${{ matrix.arch }} ./cmd/openboot
43+
44+
- name: Install UPX
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y upx-ucl
48+
49+
- name: Compress with UPX
50+
run: |
51+
upx --best --lzma openboot-${{ matrix.os }}-${{ matrix.arch }}
52+
ls -lh openboot-${{ matrix.os }}-${{ matrix.arch }}
4353
4454
- name: Upload artifact
4555
uses: actions/upload-artifact@v4

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,17 @@ test-all:
2929
build:
3030
go build -o $(BINARY_PATH) ./cmd/openboot
3131

32+
build-release:
33+
@echo "Building optimized release binary..."
34+
go build -ldflags="-s -w" -trimpath -o $(BINARY_PATH) ./cmd/openboot
35+
@echo "Original size: $$(du -h $(BINARY_PATH) | cut -f1)"
36+
@if command -v upx >/dev/null 2>&1; then \
37+
echo "Compressing with UPX..."; \
38+
upx --best --lzma $(BINARY_PATH); \
39+
echo "Compressed size: $$(du -h $(BINARY_PATH) | cut -f1)"; \
40+
else \
41+
echo "UPX not found. Install with: brew install upx"; \
42+
fi
43+
3244
clean:
3345
rm -f $(BINARY_PATH) $(COVERAGE_FILE) $(COVERAGE_HTML)

internal/cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
var (
14-
version = "0.18.1"
14+
version = "0.18.2"
1515
cfg = &config.Config{}
1616
)
1717

0 commit comments

Comments
 (0)