forked from salesforce/mirus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.gpg.sh
37 lines (28 loc) · 1.24 KB
/
.travis.gpg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# Based on: https://github.com/idealo/logback-redis/wiki/Release-Process
set -e
if [[ ! -z "$TRAVIS" && ! -z "$GPG_NAME" && ! -z "$GPG_EMAIL" ]]; then
export GPG_PASSPHRASE=$(echo "$RANDOM$(date)" | md5sum | cut -d\ -f1)
echo -e "%echo Generating a basic OpenPGP key" >> gen-key-script
echo -e "Key-Type: RSA" >> gen-key-script
echo -e "Key-Length: 4096" >> gen-key-script
echo -e "Subkey-Type: 1" >> gen-key-script
echo -e "Subkey-Length: 4096" >> gen-key-script
echo -e "Name-Real: ${GPG_NAME}" >> gen-key-script
echo -e "Name-Email: ${GPG_EMAIL}" >> gen-key-script
echo -e "Expire-Date: 1d" >> gen-key-script
echo -e "Passphrase: ${GPG_PASSPHRASE}" >> gen-key-script
echo -e "%commit" >> gen-key-script
echo -e "%echo done" >> gen-key-script
gpg --batch --gen-key gen-key-script
export GPG_KEYNAME=$(gpg -K | grep ^sec | cut -d/ -f2 | cut -d\ -f1 | head -n1)
shred gen-key-script
gpg --keyserver keyserver.ubuntu.com --send-keys ${GPG_KEYNAME}
while(true); do
date
gpg --keyserver keyserver.ubuntu.com --recv-keys ${GPG_KEYNAME} && break || sleep 30
done
else
echo "The TRAVIS, GPG_NAME, and GPG_EMAIL env vars must be set"
exit 1
fi