2021-10-30 14:50:23 +02:00
|
|
|
# macOS Universal Binaries
|
2021-10-12 19:55:43 +02:00
|
|
|
|
2021-10-14 00:58:27 +02:00
|
|
|
GoReleaser can create _macOS Universal Binaries_ - also known as _Fat Binaries_.
|
2021-10-12 19:55:43 +02:00
|
|
|
Those binaries are in a special format that contains both `arm64` and `amd64` executables in a single file.
|
|
|
|
|
|
|
|
Here's how to use it:
|
|
|
|
|
|
|
|
```yaml
|
2021-12-23 02:52:01 +02:00
|
|
|
# .goreleaser.yaml
|
2021-10-12 19:55:43 +02:00
|
|
|
universal_binaries:
|
|
|
|
-
|
2022-01-07 14:16:54 +02:00
|
|
|
# ID of resulting universal binary.
|
2021-10-12 19:55:43 +02:00
|
|
|
#
|
|
|
|
# Defaults to the project name.
|
|
|
|
id: foo
|
|
|
|
|
2022-01-07 14:16:54 +02:00
|
|
|
# IDs to use to filter the built binaries.
|
|
|
|
#
|
|
|
|
# Defaults to the `id` field.
|
|
|
|
ids:
|
|
|
|
- build1
|
|
|
|
- build2
|
|
|
|
|
2021-10-12 19:55:43 +02:00
|
|
|
# Universal binary name template.
|
|
|
|
#
|
2021-10-27 04:10:49 +02:00
|
|
|
# You will want to change this if you have multiple builds!
|
|
|
|
#
|
2021-10-12 19:55:43 +02:00
|
|
|
# Defaults to '{{ .ProjectName }}'
|
|
|
|
name_template: '{{.ProjectName}}_{{.Version}}'
|
|
|
|
|
|
|
|
# Whether to remove the previous single-arch binaries from the artifact list.
|
|
|
|
# If left as false, your end release might have both several macOS archives: amd64, arm64 and all.
|
|
|
|
#
|
|
|
|
# Defaults to false.
|
|
|
|
replace: true
|
2021-11-24 15:30:23 +02:00
|
|
|
|
|
|
|
# Hooks can be used to customize the final binary,
|
|
|
|
# for example, to run generators.
|
|
|
|
# Those fields allow templates.
|
|
|
|
# Default is both hooks empty.
|
|
|
|
hooks:
|
|
|
|
pre: rice embed-go
|
|
|
|
post: ./script.sh {{ .Path }}
|
2021-10-12 19:55:43 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
!!! tip
|
|
|
|
Learn more about the [name template engine](/customization/templates/).
|
|
|
|
|
2021-11-24 15:30:23 +02:00
|
|
|
For more info about hooks, see the [build section](/customization/build/#build-hooks).
|
2021-10-12 19:55:43 +02:00
|
|
|
|
2021-11-24 15:30:23 +02:00
|
|
|
The minimal configuration for most setups would look like this:
|
2021-10-12 19:55:43 +02:00
|
|
|
```yaml
|
|
|
|
# .goreleaser.yml
|
|
|
|
universal_binaries:
|
|
|
|
- replace: true
|
|
|
|
```
|
|
|
|
|
|
|
|
That config will join your default build macOS binaries into an Universal Binary,
|
|
|
|
removing the single-arch binaries from the artifact list.
|
|
|
|
|
|
|
|
From there, the `Arch` template variable for this file will be `all`.
|
|
|
|
You can use the Go template engine to remove it if you'd like.
|
2021-10-27 04:10:49 +02:00
|
|
|
|
|
|
|
!!! warning
|
|
|
|
You'll want to change `name_template` for each `id` you add in universal binaries, otherwise they'll have the same name.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
universal_binaries:
|
|
|
|
- id: foo
|
|
|
|
name_template: bin1
|
|
|
|
- id: bar
|
|
|
|
name_template: bin2
|
|
|
|
```
|