diff options
author | ligi <ligi@ligi.de> | 2018-05-09 07:13:53 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-05-09 07:13:53 +0800 |
commit | eab6e5a317acf67409f82bc5c1f4d959413dfd47 (patch) | |
tree | 8ffb7cd4b55ff925ba77e82677ae31e208581fae /internal | |
parent | c4a4613d9504db43a26a3c79dda8bf6be0d1237a (diff) | |
download | go-tangerine-eab6e5a317acf67409f82bc5c1f4d959413dfd47.tar go-tangerine-eab6e5a317acf67409f82bc5c1f4d959413dfd47.tar.gz go-tangerine-eab6e5a317acf67409f82bc5c1f4d959413dfd47.tar.bz2 go-tangerine-eab6e5a317acf67409f82bc5c1f4d959413dfd47.tar.lz go-tangerine-eab6e5a317acf67409f82bc5c1f4d959413dfd47.tar.xz go-tangerine-eab6e5a317acf67409f82bc5c1f4d959413dfd47.tar.zst go-tangerine-eab6e5a317acf67409f82bc5c1f4d959413dfd47.zip |
build: specify the key to use when invoking gpg:sign-and-deploy-file (#16696)
Diffstat (limited to 'internal')
-rw-r--r-- | internal/build/pgp.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/build/pgp.go b/internal/build/pgp.go index 79ab9c06f..c7d0d2339 100644 --- a/internal/build/pgp.go +++ b/internal/build/pgp.go @@ -57,3 +57,15 @@ func PGPSignFile(input string, output string, pgpkey string) error { // Generate the signature and return return openpgp.ArmoredDetachSign(out, keys[0], in, nil) } + +// PGPKeyID parses an armored key and returns the key ID. +func PGPKeyID(pgpkey string) (string, error) { + keys, err := openpgp.ReadArmoredKeyRing(bytes.NewBufferString(pgpkey)) + if err != nil { + return "", err + } + if len(keys) != 1 { + return "", fmt.Errorf("key count mismatch: have %d, want %d", len(keys), 1) + } + return keys[0].PrimaryKey.KeyIdString(), nil +} |