2017-07-19 170 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.