2017-07-19 173 views
2

我看到Travis具有用于加密文件的工作流程here如何GPG签署由Travis-CI构建的文件

我的用例稍微简单一点,我只想为在Travis-CI上构建的文件生成签名。 说:

hello-0.0.1-a.bin.asc 
hello-0.0.1-a.bin 
pubkey.gpg 
<or> hello-0.0.1-a.pub 

在这种情况下hello-0.0.1-a.bin由特拉维斯创建的构建,以及将被推到Github上的释放。 同样,签名也必须作为发布版本推送给Github(即在同一标签下)。

如果私钥/公钥对于该构建是唯一的,我并不十分关心(即不是交易断路器)。 但是,如果私钥/公钥对在构建之间共享,那将是理想的。

欣赏和提示提示或咒语。

回答

1

它基本上归结为几个步骤。

  1. 导出你的GPG钥匙圈gpg --export > all.gpg
  2. 使用travis红宝石宝石encrypt-file的GPG钥匙圈(前all.gpg
  3. 添加all.gpg.enc到您的回购协议(而不是未加密all.gpg
  4. 确保回购可以访问安全变量
  5. 将此行添加到您的.travis.yml文件中以解密您的加密的私人签名密钥

    openssl aes-256-cbc -K $encrypted_0a6446eb3ae3_key -iv $encrypted_0a6446eb3ae3_key -in all.gpg.enc -out all.gpg -d

  6. 导入GPG密钥gpg --import all.gpg

  7. 登录您的图像gpg --output hello.bin.asc --sign hello.bin
$ travis encrypt-file all.gpg --add 
encrypting all.gpg for rkh/travis-encrypt-file-example 
storing result as all.gpg.enc 
storing secure env variables for decryption 

Make sure to add all.gpg.enc to the git repository. 
Make sure not to add all.gpg to the git repository. 
Commit all changes to your .travis.yml.