Skip to content

Commit f91eb9b

Browse files
committed
travis-build.sh: enable GPG signing if feasible
If signingkey.asc.enc is present, decrypt it and import it into the GPG keyring. On the Maven side, if ~/.gnupg exists, activate a profile setting the gpg.keyname & gpg.passphrase Maven properties to match the GPG_KEY_NAME and GPG_PASSPHRASE environment variables, respectively. These changes pave the way for signing build artifacts as needed; see also the forthcoming add-travis.sh script in this repository.
1 parent ba28889 commit f91eb9b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

travis-build.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,34 @@ cat >"$settingsFile" <<EOL
3636
<password>${env.OSSRH_PASS}</password>
3737
</server>
3838
</servers>
39+
<profiles>
40+
<profile>
41+
<id>gpg</id>
42+
<activation>
43+
<file>
44+
<exists>${env.HOME}/.gnupg</exists>
45+
</file>
46+
</activation>
47+
<properties>
48+
<gpg.keyname>${env.GPG_KEY_NAME}</gpg.keyname>
49+
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
50+
</properties>
51+
</profile>
52+
</profiles>
3953
</settings>
4054
EOL
4155

56+
# Populate the GPG signing key.
57+
keyFile=.travis/signingkey.asc
58+
if [ "$TRAVIS_SECURE_ENV_VARS" = true \
59+
-a "$TRAVIS_PULL_REQUEST" = false \
60+
-a -f "$keyFile.enc" -a -e "$1" -a -e "$2" ]
61+
then
62+
echo "== Decrypting GPG keypair =="
63+
openssl aes-256-cbc -K "$1" -iv "$2" -in "$keyFile.enc" -out "$keyFile" -d &&
64+
gpg --batch --fast-import "$keyFile" --passphrase "$GPG_PASSPHRASE"
65+
fi
66+
4267
# Run the build.
4368
if [ "$TRAVIS_SECURE_ENV_VARS" = true \
4469
-a "$TRAVIS_PULL_REQUEST" = false \

0 commit comments

Comments
 (0)