2017-12-13 18:14:01 +02:00
|
|
|
---
|
|
|
|
title: Signing
|
2018-04-25 07:20:12 +02:00
|
|
|
series: customization
|
|
|
|
hideFromIndex: true
|
|
|
|
weight: 60
|
2017-12-13 18:14:01 +02:00
|
|
|
---
|
|
|
|
|
2020-04-14 05:41:39 +02:00
|
|
|
Signing ensures that the artifacts have been generated by yourself and your
|
|
|
|
users can verify that by comparing the generated signature with your public
|
|
|
|
signing key.
|
|
|
|
|
|
|
|
GoReleaser provides means to sign both executables and archives.
|
|
|
|
|
|
|
|
## Archives
|
2017-12-13 18:14:01 +02:00
|
|
|
|
|
|
|
Signing works in combination with checksum files and it is generally sufficient
|
2017-12-13 23:57:24 +02:00
|
|
|
to sign the checksum files only.
|
2017-12-13 18:14:01 +02:00
|
|
|
|
|
|
|
The default is configured to create a detached signature for the checksum files
|
2017-12-20 12:32:21 +02:00
|
|
|
with [GnuPG](https://www.gnupg.org/) and your default key. To enable signing
|
2017-12-13 18:14:01 +02:00
|
|
|
just add
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
# goreleaser.yml
|
2019-07-21 23:46:46 +02:00
|
|
|
signs:
|
|
|
|
- artifacts: checksum
|
2017-12-13 18:14:01 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
To customize the signing pipeline you can use the following options:
|
|
|
|
|
|
|
|
```yml
|
|
|
|
# .goreleaser.yml
|
2019-07-21 23:46:46 +02:00
|
|
|
signs:
|
|
|
|
-
|
2020-01-30 05:21:45 +02:00
|
|
|
# ID of the sign config, must be unique.
|
|
|
|
# Defaults to "default".
|
|
|
|
id: foo
|
|
|
|
|
2019-07-21 23:46:46 +02:00
|
|
|
# name of the signature file.
|
|
|
|
# '${artifact}' is the path to the artifact that should be signed.
|
|
|
|
#
|
|
|
|
# defaults to `${artifact}.sig`
|
|
|
|
signature: "${artifact}_sig"
|
|
|
|
|
|
|
|
# path to the signature command
|
|
|
|
#
|
|
|
|
# defaults to `gpg`
|
|
|
|
cmd: gpg2
|
|
|
|
|
|
|
|
# command line arguments for the command
|
|
|
|
#
|
|
|
|
# to sign with a specific key use
|
|
|
|
# args: ["-u", "<key id, fingerprint, email, ...>", "--output", "${signature}", "--detach-sign", "${artifact}"]
|
|
|
|
#
|
|
|
|
# defaults to `["--output", "${signature}", "--detach-sign", "${artifact}"]`
|
|
|
|
args: ["--output", "${signature}", "${artifact}"]
|
|
|
|
|
|
|
|
|
|
|
|
# which artifacts to sign
|
|
|
|
#
|
|
|
|
# checksum: only checksum file(s)
|
|
|
|
# all: all artifacts
|
|
|
|
# none: no signing
|
|
|
|
#
|
|
|
|
# defaults to `none`
|
|
|
|
artifacts: all
|
2019-11-08 14:10:56 +02:00
|
|
|
|
|
|
|
# IDs of the artifacts to sign.
|
|
|
|
# Defaults to all.
|
|
|
|
# If `artifacts` is checksum, this fields has no effect.
|
|
|
|
ids:
|
|
|
|
- foo
|
|
|
|
- bar
|
2017-12-13 18:14:01 +02:00
|
|
|
```
|
2019-12-27 04:14:40 +02:00
|
|
|
|
2020-04-14 05:41:39 +02:00
|
|
|
### Limitations
|
2020-01-30 15:09:47 +02:00
|
|
|
|
|
|
|
You can sign with any command that outputs a file.
|
|
|
|
If what you want to use does not do it, you can always hack by setting the
|
|
|
|
command to `sh -c`. For example:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
# goreleaser.yml
|
|
|
|
signs:
|
|
|
|
- cmd: sh
|
|
|
|
args:
|
|
|
|
- '-c'
|
|
|
|
- 'echo "${artifact} is signed and I can prove it" | tee ${signature}'
|
|
|
|
artifacts: all
|
|
|
|
```
|
|
|
|
|
|
|
|
And it will work just fine. Just make sure to always use the `${signature}`
|
|
|
|
template variable as the result file name and `${artifact}` as the origin file.
|
|
|
|
|
|
|
|
|
2020-04-14 05:41:39 +02:00
|
|
|
## Executables
|
|
|
|
|
|
|
|
Executables can be signed after build using post hooks.
|
2019-12-27 04:14:40 +02:00
|
|
|
|
2020-04-14 05:41:39 +02:00
|
|
|
For example you can use [gon][] to create notarized MacOS apps:
|
2019-12-27 04:14:40 +02:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
builds:
|
|
|
|
- binary: foo
|
|
|
|
id: foo
|
|
|
|
goos:
|
|
|
|
- linux
|
|
|
|
- windows
|
|
|
|
goarch:
|
|
|
|
- amd64
|
2020-04-14 05:41:39 +02:00
|
|
|
|
|
|
|
# notice that we need a separated build for the MacOS binary only:
|
2019-12-27 04:14:40 +02:00
|
|
|
- binary: foo
|
|
|
|
id: foo-macos
|
|
|
|
goos:
|
|
|
|
- darwin
|
|
|
|
goarch:
|
|
|
|
- amd64
|
2020-04-14 05:41:39 +02:00
|
|
|
hooks:
|
|
|
|
post: gon gon.hcl
|
2019-12-27 04:14:40 +02:00
|
|
|
```
|
2020-04-14 05:41:39 +02:00
|
|
|
**`gon.hcl`:**
|
|
|
|
```hcl
|
|
|
|
# The path follows a pattern
|
|
|
|
# ./dist/BUILD-ID_TARGET/BINARY-NAME
|
|
|
|
source = ["./dist/foo-macos_darwin_amd64/foo"]
|
|
|
|
bundle_id = "com.mitchellh.example.terraform"
|
|
|
|
|
|
|
|
apple_id {
|
|
|
|
username = "mitchell@example.com"
|
|
|
|
password = "@env:AC_PASSWORD"
|
|
|
|
}
|
|
|
|
|
|
|
|
sign {
|
|
|
|
application_identity = "Developer ID Application: Mitchell Hashimoto"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Note that notarizing may take some time, and will need to be run from a MacOS machine.
|
2019-12-27 04:14:40 +02:00
|
|
|
|
2020-04-14 05:41:39 +02:00
|
|
|
If you generate ZIP or DMG as part of your signing via gon you may need
|
|
|
|
to ensure their file names align with desired pattern of other artifacts
|
|
|
|
as GoReleaser doesn't control how these get generated beyond just executing `gon`
|
|
|
|
with given arguments. Relatedly you may need to list these additional artifacts
|
|
|
|
as `extra_files` in the `release` section to make sure they also get uploaded.
|
2019-12-27 04:14:40 +02:00
|
|
|
|
|
|
|
You can also check [this issue](https://github.com/goreleaser/goreleaser/issues/1227) for more details.
|
|
|
|
|
|
|
|
[gon]: https://github.com/mitchellh/gon
|