github.com/goreleaser/goreleaser@v1.25.1/www/docs/customization/upx.md (about) 1 # UPX 2 3 > Since: v1.18 4 5 Having small binary sizes are important, and Go is known for generating rather 6 big binaries. 7 8 GoReleaser has had `-s -w` as default `ldflags` since the beginning, which help 9 shaving off some bytes, but if you want to shave it even more, [`upx`][upx] is 10 the _de facto_ tool for the job. 11 12 GoReleaser has been able to integrate with it via custom [build hooks][bhooks], 13 and now UPX has its own configuration section: 14 15 !!! warning "Compatibility" 16 17 `upx` does not support all platforms! Make sure to check 18 [their issues][upx-issues] and to test your packed binaries. 19 20 Namely, _macOS Ventura_ is not supported at the moment. 21 22 ```yaml 23 # .goreleaser.yaml 24 upx: 25 - # Whether to enable it or not. 26 # 27 # Templates: allowed (since v1.21) 28 enabled: true 29 30 # Filter by build ID. 31 ids: [build1, build2] 32 33 # Filter by GOOS. 34 # 35 # Since: v1.19 36 goos: [linux, darwin] 37 38 # Filter by GOARCH. 39 # 40 # Since: v1.19 41 goarch: [arm, amd64] 42 43 # Filter by GOARM. 44 # 45 # Since: v1.19 46 goarm: [8] 47 48 # Filter by GOAMD64. 49 # 50 # Since: v1.19 51 goamd64: [v1] 52 53 # Compress argument. 54 # Valid options are from '1' (faster) to '9' (better), and 'best'. 55 compress: best 56 57 # Whether to try LZMA (slower). 58 lzma: true 59 60 # Whether to try all methods and filters (slow). 61 brute: true 62 ``` 63 64 !!! info 65 66 If `upx` is not in `$PATH`, GoReleaser will automatically avoid running it. 67 68 Notice you can define multiple `upx` definitions, filtering by various fields. 69 You can use that to have different compression options depending on the target 70 OS, for instance - or even to run it only on a few selected platforms. 71 72 !!! tip 73 74 Learn more about the [name template engine](templates.md). 75 76 [upx]: https://upx.github.io/ 77 [upx-issues]: https://github.com/upx/upx/issues 78 [bhooks]: /customization/builds/#build-hooks