如何GPG签署由Travis-CI构建的文件

Hed*_*hog 6 travis-ci gpg-signature

我看到特拉维斯具有加密文件,工作流在这里.

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

hello-0.0.1-a.bin.asc
hello-0.0.1-a.bin
pubkey.gpg 
<or> hello-0.0.1-a.pub
Run Code Online (Sandbox Code Playgroud)

在这种情况下hello-0.0.1-a.bin,由Travis构建创建,并将作为发布推送到Github.同样,签名也必须作为版本推送到Github(即在同一标签下).

如果私有/公共密钥对对于该构建是唯一的,我不会非常关心(即不是交易破坏者).但如果私有/公共密钥对在构建之间共享,那将是理想的.

欣赏并提示提示或咒语.

Ste*_*enG 8

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

  1. 导出你的gpg密钥环 gpg --export-secret-keys > all.gpg
  2. 使用travisruby gem到encrypt-filegpg keyring(ex all.gpg)
  3. 添加all.gpg.enc到您的仓库(不是未加密的all.gpg)
  4. 确保repo可以访问安全变量
  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.
Run Code Online (Sandbox Code Playgroud)