fix(size): reduced build size by 33% (#78) (#97)

Drew Smirnoff created

Change summary

.goreleaser.yml |  5 ++++-
CONTRIBUTING.md |  2 +-
README.md       | 12 +++++++++++-
3 files changed, 16 insertions(+), 3 deletions(-)

Detailed changes

.goreleaser.yml 🔗

@@ -26,9 +26,12 @@ builds:
     # Environment variables to pass to the Go compiler.
     env:
       - CGO_ENABLED=0
+    # Build flags for smaller binaries and reproducible builds.
+    flags:
+      - -trimpath
     # Linker flags to strip debug information and reduce binary size.
     ldflags:
-      - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
+      - -s -w -buildid= -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
 
 # 'archives' defines how to package the built binaries.
 # 'archives' defines how to package the built binaries.

CONTRIBUTING.md 🔗

@@ -46,7 +46,7 @@ To get started with development, you'll need to have Go installed.
     ```
 3.  Build the project:
     ```bash
-    go build -o matcha
+    go build -trimpath -ldflags="-s -w" -o matcha
     ```
 4.  Run the application:
     ```bash

README.md 🔗

@@ -98,9 +98,19 @@ Matcha is written in **Go**. To build it manually:
 4.  Build the binary:
 
     ```bash
-    go build -o matcha
+    go build -trimpath -ldflags="-s -w" -o matcha
     ```
 
+    For an even smaller binary, compress with UPX (install via `brew install upx` or `apt install upx`):
+
+    ```bash
+    upx --best --lzma matcha
+    ```
+    
+    > [!WARNING] 
+    > UPX compression does NOT work on macOS ARM builds. See [#97](https://github.com/floatpane/matcha/pull/97)
+  
+
 5.  Run it:
     ```bash
     ./matcha