You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-15 01:34:21 +02:00
@ -11,7 +11,7 @@ Here is a commented `builds` section with all fields specified:
|
||||
# .goreleaser.yaml
|
||||
builds:
|
||||
# You can have multiple builds defined as a yaml list
|
||||
-
|
||||
- #
|
||||
# ID of the build.
|
||||
#
|
||||
# Default: Binary name
|
||||
@ -183,7 +183,7 @@ builds:
|
||||
# Set the modified timestamp on the output binary, typically
|
||||
# you would do this to ensure a build was reproducible. Pass
|
||||
# empty string to skip modifying the output.
|
||||
mod_timestamp: '{{ .CommitTimestamp }}'
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
|
||||
# Hooks can be used to customize the final binary,
|
||||
# for example, to run generators.
|
||||
@ -241,8 +241,8 @@ builds:
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
goamd64: v1
|
||||
goarm: ''
|
||||
gomips: ''
|
||||
goarm: ""
|
||||
gomips: ""
|
||||
ldflags:
|
||||
- foo
|
||||
tags:
|
||||
@ -256,9 +256,11 @@ builds:
|
||||
```
|
||||
|
||||
!!! tip
|
||||
|
||||
Learn more about the [name template engine](/customization/templates/).
|
||||
|
||||
!!! info
|
||||
|
||||
First-class build targets are gathered by running:
|
||||
```sh
|
||||
go tool dist list -json | jq -r '.[] | select(.FirstClass) | [.GOOS, .GOARCH] | @tsv'
|
||||
@ -300,13 +302,13 @@ following build details are exposed:
|
||||
|
||||
<!-- to format the tables, use: https://tabletomarkdown.com/format-markdown-table/ -->
|
||||
|
||||
Key |Description
|
||||
-------|---------------------------------
|
||||
.Os |`GOOS`
|
||||
.Arch |`GOARCH`
|
||||
.Arm |`GOARM`
|
||||
.Ext |Extension, e.g. `.exe`
|
||||
.Target|Build target, e.g. `darwin_amd64`
|
||||
| Key | Description |
|
||||
| ------- | --------------------------------- |
|
||||
| .Os | `GOOS` |
|
||||
| .Arch | `GOARCH` |
|
||||
| .Arm | `GOARM` |
|
||||
| .Ext | Extension, e.g. `.exe` |
|
||||
| .Target | Build target, e.g. `darwin_amd64` |
|
||||
|
||||
## Passing environment variables to ldflags
|
||||
|
||||
@ -339,8 +341,7 @@ environments.
|
||||
```yaml
|
||||
# .goreleaser.yaml
|
||||
builds:
|
||||
-
|
||||
id: "with-hooks"
|
||||
- id: "with-hooks"
|
||||
targets:
|
||||
- "darwin_amd64"
|
||||
- "windows_amd64"
|
||||
@ -358,15 +359,15 @@ Each hook can also have its own work directory and environment variables:
|
||||
```yaml
|
||||
# .goreleaser.yaml
|
||||
builds:
|
||||
-
|
||||
id: "with-hooks"
|
||||
- id: "with-hooks"
|
||||
targets:
|
||||
- "darwin_amd64"
|
||||
- "windows_amd64"
|
||||
hooks:
|
||||
pre:
|
||||
- cmd: first-script.sh
|
||||
dir: "{{ dir .Dist}}"
|
||||
dir:
|
||||
"{{ dir .Dist}}"
|
||||
# Always print command output, otherwise only visible in debug mode.
|
||||
# Since: v1.5
|
||||
output: true
|
||||
@ -381,15 +382,14 @@ available (as these run _after_ the build).
|
||||
Additionally the following build details are exposed to both `pre` and `post`
|
||||
hooks:
|
||||
|
||||
|
||||
<!-- to format the tables, use: https://tabletomarkdown.com/format-markdown-table/ -->
|
||||
|
||||
Key |Description
|
||||
-------|--------------------------------------
|
||||
.Name |Filename of the binary, e.g. `bin.exe`
|
||||
.Ext |Extension, e.g. `.exe`
|
||||
.Path |Absolute path to the binary
|
||||
.Target|Build target, e.g. `darwin_amd64`
|
||||
| Key | Description |
|
||||
| ------- | -------------------------------------- |
|
||||
| .Name | Filename of the binary, e.g. `bin.exe` |
|
||||
| .Ext | Extension, e.g. `.exe` |
|
||||
| .Path | Absolute path to the binary |
|
||||
| .Target | Build target, e.g. `darwin_amd64` |
|
||||
|
||||
Environment variables are inherited and overridden in the following order:
|
||||
|
||||
@ -428,20 +428,21 @@ To make your releases, checksums and signatures reproducible, you will need to
|
||||
make some (if not all) of the following modifications to the build defaults in
|
||||
GoReleaser:
|
||||
|
||||
* Modify `ldflags`: by default `main.Date` is set to the time GoReleaser is run
|
||||
- Modify `ldflags`: by default `main.Date` is set to the time GoReleaser is run
|
||||
(`{{.Date}}`), you can set this to `{{.CommitDate}}` or just not pass the
|
||||
variable.
|
||||
* Modify `mod_timestamp`: by default this is empty string — which means it'll be
|
||||
- Modify `mod_timestamp`: by default this is empty string — which means it'll be
|
||||
the compilation time, set to `{{.CommitTimestamp}}` or a constant value
|
||||
instead.
|
||||
* If you do not run your builds from a consistent directory structure, pass
|
||||
- If you do not run your builds from a consistent directory structure, pass
|
||||
`-trimpath` to `flags`.
|
||||
* Remove uses of the `time` template function. This function returns a new value
|
||||
- Remove uses of the `time` template function. This function returns a new value
|
||||
on every call and is not deterministic.
|
||||
|
||||
## Import pre-built binaries
|
||||
|
||||
!!! success "GoReleaser Pro"
|
||||
|
||||
The prebuilt builder is a [GoReleaser Pro feature](/pro/).
|
||||
|
||||
It is also possible to import pre-built binaries into the GoReleaser lifecycle.
|
||||
@ -458,8 +459,7 @@ In any case, its pretty easy to do that now:
|
||||
```yaml
|
||||
# .goreleaser.yaml
|
||||
builds:
|
||||
-
|
||||
# Set the builder to prebuilt
|
||||
- # Set the builder to prebuilt
|
||||
builder: prebuilt
|
||||
|
||||
# When builder is `prebuilt` there are no defaults for goos, goarch,
|
||||
@ -480,8 +480,17 @@ builds:
|
||||
# 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
|
||||
```
|
||||
|
||||
!!! tip
|
||||
|
||||
You can think of `prebuilt.path` as being the "external path" and the
|
||||
`binary` as being the "internal path to binary".
|
||||
|
||||
This example config will import into your release pipeline the following
|
||||
binaries:
|
||||
|
||||
@ -495,6 +504,7 @@ itself.
|
||||
There is no difference in how the binaries are handled.
|
||||
|
||||
!!! tip
|
||||
|
||||
A cool tip here, specially when using CGO, is that you can have one
|
||||
`.goreleaser.yaml` file just for the builds, build each in its own machine
|
||||
with [`goreleaser build --single-target`](/cmd/goreleaser_build/) and
|
||||
@ -504,11 +514,13 @@ There is no difference in how the binaries are handled.
|
||||
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 `prebuilt` binary, there are no defaults for `goos`,
|
||||
`goarch`, `goarm`, `gomips` and `goamd64`.
|
||||
You'll need to either provide them or the final `targets` matrix.
|
||||
@ -560,16 +572,15 @@ attempt to configure any additional logic.
|
||||
|
||||
GoReleaser will:
|
||||
|
||||
* set the correct file extension for the target OS.
|
||||
* package the generated header file (`.h`) in the release bundle.
|
||||
- set the correct file extension for the target OS.
|
||||
- package the generated header file (`.h`) in the release bundle.
|
||||
|
||||
Example usage:
|
||||
|
||||
```yaml
|
||||
# .goreleaser.yaml
|
||||
builds:
|
||||
-
|
||||
id: "my-library"
|
||||
- id: "my-library"
|
||||
|
||||
# Configure the buildmode flag to output a shared library
|
||||
buildmode: "c-shared" # or "c-archive" for a static library
|
||||
|
Reference in New Issue
Block a user