Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,10 @@ jobs:
if: matrix.target != 'x86_64-unknown-linux-gnu' && matrix.target != 'x86_64-apple-darwin' && matrix.target != 'aarch64-apple-darwin'
run: cross build --release --target ${{ matrix.target }}

- name: Install UPX
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
# Download and install UPX for Linux
curl -L https://github.com/upx/upx/releases/download/v4.2.1/upx-4.2.1-amd64_linux.tar.xz | tar xJ
sudo mv upx-4.2.1-amd64_linux/upx /usr/local/bin/
elif [ "${{ runner.os }}" = "macOS" ]; then
# Install UPX via Homebrew on macOS
brew install upx
fi
shell: bash

- name: Rename and compress binary
- name: Rename binary
run: |
if [ -f "target/${{ matrix.target }}/release/fls" ]; then
cp "target/${{ matrix.target }}/release/fls" "${{ matrix.artifact_name }}"
echo "Original size:"
ls -lh "${{ matrix.artifact_name }}"
# Compress with UPX
upx --best --lzma "${{ matrix.artifact_name }}" || echo "UPX compression failed, using uncompressed binary"
echo "Compressed size:"
ls -lh "${{ matrix.artifact_name }}"
fi
shell: bash
Expand Down
33 changes: 2 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,41 +78,12 @@ jobs:
if: matrix.target != 'x86_64-unknown-linux-gnu' && matrix.target != 'x86_64-apple-darwin' && matrix.target != 'aarch64-apple-darwin'
run: cross build --release --target ${{ matrix.target }}

- name: Install UPX
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
# Download and install UPX for Linux
curl -L https://github.com/upx/upx/releases/download/v4.2.1/upx-4.2.1-amd64_linux.tar.xz | tar xJ
sudo mv upx-4.2.1-amd64_linux/upx /usr/local/bin/
elif [ "${{ runner.os }}" = "macOS" ]; then
# Install UPX via Homebrew on macOS
brew install upx
fi
upx --version
shell: bash

- name: Prepare and compress binary
- name: Prepare binary
run: |
if [ -f "target/${{ matrix.target }}/release/fls" ]; then
cp "target/${{ matrix.target }}/release/fls" "${{ matrix.artifact_name }}"

echo "📦 Original binary size:"
ls -lh "${{ matrix.artifact_name }}"
original_size=$(stat -f%z "${{ matrix.artifact_name }}" 2>/dev/null || stat -c%s "${{ matrix.artifact_name }}")

# Compress with UPX
echo "🗜️ Compressing with UPX --best --lzma..."
if upx --best --lzma "${{ matrix.artifact_name }}"; then
echo "✅ Compression successful!"
ls -lh "${{ matrix.artifact_name }}"
compressed_size=$(stat -f%z "${{ matrix.artifact_name }}" 2>/dev/null || stat -c%s "${{ matrix.artifact_name }}")
ratio=$(awk "BEGIN {printf \"%.1f\", ($original_size - $compressed_size) * 100 / $original_size}")
echo "📉 Size reduction: ${ratio}%"
else
echo "⚠️ UPX compression failed, using uncompressed binary"
fi

# Create checksum

if command -v sha256sum &> /dev/null; then
sha256sum "${{ matrix.artifact_name }}" > "${{ matrix.artifact_name }}.sha256"
else
Expand Down
10 changes: 1 addition & 9 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ RUN apt-get update && apt-get install -y \
make \
perl \
file \
upx-ucl \
&& rm -rf /var/lib/apt/lists/*

# Add ARM64 glibc target
Expand Down Expand Up @@ -50,12 +49,5 @@ COPY src src
# Build the actual project (dependencies are already cached)
RUN cargo build --release --target aarch64-unknown-linux-gnu

# Compress the binary with UPX for smaller size
# Using --best for maximum compression, --lzma for best algorithm
# UPX compresses in-place, so the original binary will be compressed
RUN cd target/aarch64-unknown-linux-gnu/release && \
upx --best --lzma fls || \
echo "UPX compression failed, using uncompressed binary"

# The compressed binary will be in target/aarch64-unknown-linux-gnu/release/fls
# The binary will be in target/aarch64-unknown-linux-gnu/release/fls

48 changes: 1 addition & 47 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for fls - ARM64 static builds

.PHONY: all build clean test arm64-static lint fmt clippy check help compress-upx
.PHONY: all build clean test arm64-static lint fmt clippy check help

# Default target
all: build
Expand All @@ -9,10 +9,6 @@ all: build
build:
cargo build --release

# Build and compress for native target
build-compressed: build
@$(MAKE) compress-upx BINARY=target/release/fls OUTPUT=fls-native

# Build for ARM64 static (musl) using cross
arm64-static:
rustup target add aarch64-unknown-linux-musl
Expand All @@ -24,10 +20,6 @@ arm64-static:
ls -lh fls-arm64-static; \
fi

# Build ARM64 static and compress with UPX
arm64-static-compressed: arm64-static
@$(MAKE) compress-upx BINARY=fls-arm64-static OUTPUT=fls-arm64-static

# Build for all targets (native + ARM64 static)
all-targets:
./build.sh
Expand Down Expand Up @@ -59,39 +51,6 @@ check:
@echo "Running cargo check..."
cargo check --all-targets

# Compress a binary with UPX
# Usage: make compress-upx BINARY=path/to/binary OUTPUT=output-name
compress-upx:
@if [ -z "$(BINARY)" ] || [ -z "$(OUTPUT)" ]; then \
echo "Error: BINARY and OUTPUT must be specified"; \
echo "Usage: make compress-upx BINARY=path/to/binary OUTPUT=output-name"; \
exit 1; \
fi
@if ! command -v upx >/dev/null 2>&1; then \
echo "Error: UPX not found. Install it first:"; \
echo " macOS: brew install upx"; \
echo " Linux: apt-get install upx-ucl or download from https://github.com/upx/upx/releases"; \
exit 1; \
fi
@if [ -f "$(BINARY)" ]; then \
if [ "$(BINARY)" != "$(OUTPUT)" ]; then \
cp "$(BINARY)" "$(OUTPUT)"; \
fi; \
echo "📦 Original size:"; \
ls -lh "$(OUTPUT)"; \
echo "🗜️ Compressing with UPX --best --lzma..."; \
if upx --best --lzma "$(OUTPUT)"; then \
echo "✅ Compression successful!"; \
ls -lh "$(OUTPUT)"; \
else \
echo "⚠️ UPX compression failed"; \
exit 1; \
fi; \
else \
echo "Error: Binary $(BINARY) not found"; \
exit 1; \
fi

# Clean build artifacts
clean:
cargo clean
Expand All @@ -111,14 +70,9 @@ help:
@echo ""
@echo "Build targets:"
@echo " build - Build for native target"
@echo " build-compressed - Build for native target and compress with UPX"
@echo " arm64-static - Build for ARM64 static (musl)"
@echo " arm64-static-compressed - Build for ARM64 static and compress with UPX"
@echo " all-targets - Build for native + ARM64 static"
@echo ""
@echo "Compression:"
@echo " compress-upx - Compress a binary with UPX (requires BINARY and OUTPUT args)"
@echo ""
@echo "Testing and Quality:"
@echo " test - Run tests"
@echo " lint - Run all lints (format check + clippy)"
Expand Down
Loading