github.phpd.cn/goreleaser/goreleaser@v0.92.0/internal/pipe/sign/testdata/README.md (about) 1 # Creating test keys for GnuPG 2 3 The unit tests needs a test key to work with. I have tried to create a test keyring 4 on the fly and while that worked I was not able to successfully sign with that. 5 gpg would bail with an ioctl error which I didn't track down since using a static 6 key works. 7 8 This uses the `--homedir .` option to create the test keys so that we do not touch 9 the local keyring file. 10 11 1. Create signing keys 12 13 cd $GOPATH/src/github.com/goreleaser/goreleaser/internal/pipeline/sign/testdata/gnupg 14 gpg --homedir . --quick-generate-key --batch --passphrase '' nopass default default 10y 15 16 1. Check that the key exists 17 18 ## $ gpg --homedir . --list-keys 19 20 pub rsa2048 2017-12-13 [SC][expires: 2027-12-11] 21 FB6BEDFCECE1761EDD68BF32EF2D274B0EDAAE12 22 uid [ultimate] nopass 23 sub rsa2048 2017-12-13 [E] 24 25 1) Check that signing works 26 27 # create a test file 28 29 echo "bar" > foo 30 31 # sign and verfiy 32 33 gpg --homedir . --detach-sign foo 34 gpg --homedir . --verify foo.sig foo 35 36 gpg: Signature made Wed Dec 13 22:02:49 2017 CET 37 gpg: using RSA key FB6BEDFCECE1761EDD68BF32EF2D274B0EDAAE12 38 gpg: Good signature from "nopass" [ultimate] 39 40 # cleanup 41 42 rm foo foo.sig 43 44 1) Make sure you have keyrings for both gpg1 and gpg2 45 46 travis-ci.org runs on an old Ubuntu installation which 47 has gpg 1.4 installed. We need to provide keyrings that 48 have the same keys and users for both formats. 49 50 This demonstrates the conversion from gpg2 to gpg1 51 format but should work the same the other way around. 52 53 # get gpg version 54 55 gpg --version 56 gpg (GnuPG) 2.2.3 57 ... 58 59 # install gpg1 60 61 brew install gpg1 62 63 # brew install gpg2 # if you have gpg1 installed 64 65 # migrate the keys from gpg2 to gpg1 66 67 gpg --homedir . --export nopass | gpg1 --homedir . --import 68 gpg --homedir . --export-secret-key nopass | gpg1 --homedir . --import 69 70 # check keys are the same 71 72 gpg --homedir . --list-keys --keyid-format LONG 73 gpg1 --homedir . --list-keys --keyid-format LONG 74 75 gpg --homedir . --list-secret-keys --keyid-format LONG 76 gpg1 --homedir . --list-secret-keys --keyid-format LONG 77 78 ``` 79 80 ```