diff --git a/.goreleaser.yml b/.goreleaser.yml index 4c403da69dbfb1898b18a60da64acb34c482990a..e951ddc2133de4765ba7269167276bb3d6fa3536 100644 --- a/.goreleaser.yml +++ b/.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. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd41d79be8dbb130800a201dcb7fba938005d3ef..749bc3ad0172ae3adbcc166c7cb6a93d47088001 100644 --- a/CONTRIBUTING.md +++ b/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 diff --git a/README.md b/README.md index 36131e85b5df986f554d795559939cadc0077f7c..26c03d28354c94c0bc53de1cb6ef7b5ae08bc488 100644 --- a/README.md +++ b/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