@@ -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.
@@ -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
@@ -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