www/content/customization/builds/builders/prebuilt.md
{{< g_featpro >}}
It is also possible to import pre-built binaries into the GoReleaser lifecycle.
Reasons you might want to do that include:
Makefile or other toolIn any case, its pretty easy to do that now:
builds:
- # Set the builder to prebuilt
builder: prebuilt
# When builder is `prebuilt` there are no defaults for goos, goarch,
# goarm, gomips, goamd64 and targets, so you always have to specify them:
goos:
- linux
- darwin
goarch:
- amd64
- arm64
goamd64:
- v1
# prebuilt specific options
prebuilt:
# Path must be the template path to the binaries.
# GoReleaser removes the `dist` directory before running, so you will likely
# want to put the binaries elsewhere.
# This field is required when using the `prebuilt` builder.
path: output/mybin_{{ .Os }}_{{ .Arch }}{{ with .Amd64 }}_{{ . }}{{ end }}/mybin
# Use 'binary' to set the final name of your binary.
# This is the name that will be used in archives et al.
binary: bin/mybin
[!NOTE] You can think of
prebuilt.pathas being the "external path" and thebinaryas being the "internal path to binary".
This example config will import into your release pipeline the following binaries:
output/mybin_linux_amd64_v1output/mybin_linux_arm64output/mybin_darwin_amd64_v1output/mybin_darwin_arm64The other steps of the pipeline will act as if those were built by GoReleaser itself. There is no difference in how the binaries are handled.
[!NOTE] A cool tip here, specially when using CGO, is that you can have one
.goreleaser.yamlfile just for the builds, build each in its own machine withgoreleaser build --single-targetand have a second.goreleaser.yamlfile that imports those binaries and release them. This tip can also be used to speed up the build process if you run all the builds in different machines in parallel.
[!WARNING] GoReleaser will try to stat the final path, if any error happens while doing that (e.g. file does not exist or permission issues), GoReleaser will fail.
[!WARNING] When using the
prebuiltbinary, there are no defaults forgoos,goarch,goarm,gomipsandgoamd64. You'll need to either provide them or the finaltargetsmatrix.
If you'd like to see this in action, check this example on GitHub.