github.com/goreleaser/goreleaser@v1.25.1/www/docs/customization/universalbinaries.md (about) 1 # macOS Universal Binaries 2 3 GoReleaser can create _macOS Universal Binaries_ - also known as _Fat Binaries_. 4 Those binaries are in a special format that contains both `arm64` and `amd64` 5 executables in a single file. 6 7 Here's how to use it: 8 9 ```yaml 10 # .goreleaser.yaml 11 universal_binaries: 12 - # ID of the resulting universal binary. 13 # 14 # Default: the project name 15 id: foo 16 17 # IDs to use to filter the built binaries. 18 # 19 # Notice that you shouldn't include different apps' IDs here. 20 # This field is usually only required if you are using CGO. 21 # 22 # Default: the value of the id field 23 # Since: v1.3 24 ids: 25 - build1 26 - build2 27 28 # Universal binary name. 29 # 30 # You will want to change this if you have multiple builds! 31 # 32 # Default: '{{ .ProjectName }}' 33 # Templates: allowed 34 name_template: "{{.ProjectName}}_{{.Version}}" 35 36 # Whether to remove the previous single-arch binaries from the artifact list. 37 # If left as false, your end release might have as much as three 38 # archives for macOS: 'amd64', 'arm64' and 'all'. 39 replace: true 40 41 # Set the modified timestamp on the output binary, typically 42 # you would do this to ensure a build was reproducible. 43 # Pass an empty string to skip modifying the output. 44 # 45 # Since: v1.20 46 # Templates: allowed 47 mod_timestamp: "{{ .CommitTimestamp }}" 48 49 # Hooks can be used to customize the final binary, 50 # for example, to run generators. 51 # 52 # Templates: allowed 53 hooks: 54 pre: rice embed-go 55 post: ./script.sh {{ .Path }} 56 ``` 57 58 !!! tip 59 60 Learn more about the [name template engine](/customization/templates/). 61 62 For more info about hooks, see the [build section](./builds.md#build-hooks). 63 64 The minimal configuration for most setups would look like this: 65 66 ```yaml 67 # .goreleaser.yml 68 universal_binaries: 69 - replace: true 70 ``` 71 72 That config will join your default build macOS binaries into a Universal Binary, 73 removing the single-arch binaries from the artifact list. 74 75 From there, the `Arch` template variable for this file will be `all`. 76 You can use the Go template engine to remove it if you'd like. 77 78 !!! warning 79 80 You'll want to change `name_template` for each `id` you add in universal 81 binaries, otherwise they'll have the same name. 82 83 Example: 84 85 ```yaml 86 universal_binaries: 87 - id: foo 88 name_template: bin1 89 - id: bar 90 name_template: bin2 91 ``` 92 93 ## Naming templates 94 95 Most fields that support [templates](/customization/templates/) will also 96 support the following build details: 97 98 <!-- to format the tables, use: https://tabletomarkdown.com/format-markdown-table/ --> 99 100 | Key | Description | 101 | ------- | --------------------------------- | 102 | .Os | `GOOS`, always `darwin` | 103 | .Arch | `GOARCH`, always `all` | 104 | .Arm | `GOARM`, always empty | 105 | .Ext | Extension, always empty | 106 | .Target | Build target, always `darwin_all` | 107 | .Path | The binary path | 108 | .Name | The binary name | 109 110 !!! tip 111 112 Notice that `.Path` and `.Name` will only be available after they are 113 evaluated, so they are mostly only useful in the `post` hooks.