Skip to content

Commit e4a3637

Browse files
committed
travisify.sh: change how GPG decryption is done
We now pass the key and iv values to the travis-build.sh script, rather than letting the "travis encrypt-file" command add it to the .travis.yml file directly. Because when the travis tool does it, it does not ensure the encrypted environment variables are actually set.
1 parent 9190157 commit e4a3637

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

travisify.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,16 @@ EOL
177177
if [ -f "$signingKeySourceFile" ]
178178
then
179179
info "Encrypting $signingKeyDestFile"
180-
# NB: We have to copy the file first, so that --add does the right thing.
181-
$EXEC cp "$signingKeySourceFile" "$signingKeyDestFile"
182-
$EXEC travis encrypt-file "$signingKeyDestFile" "$signingKeyDestFile.enc" --add --repo "$repoSlug"
183-
# NB: Decrypt only when secure env vars are set.
184-
# Without this adjustment, all PR builds will fail.
185-
$EXEC perl -0777 -i -pe 's/\n- (openssl aes-256-cbc)/\n- test "\$TRAVIS_SECURE_ENV_VARS" = true &&\n \1/igs' .travis.yml
186-
$EXEC rm -f "$signingKeyDestFile"
187-
$EXEC git add "$travisConfig" "$signingKeyDestFile.enc"
188-
$EXEC git commit -m "Travis: add encrypted GPG signing keypair"
180+
if [ -z "$EXEC" ]
181+
then
182+
encryptResult=$(travis encrypt-file "$signingKeySourceFile" "$signingKeyDestFile.enc" --repo "$repoSlug" | grep openssl)
183+
key=$(echo "$encryptResult" | cut -d' ' -f4)
184+
iv=$(echo "$encryptResult" | cut -d' ' -f6)
185+
sed -i.bak "s/\(sh travis-build.sh\)/\1 $key $iv/" "$travisBuildScript"
186+
rm -f "$travisBuildScript.bak"
187+
git add "$travisBuildScript" "$signingKeyDestFile.enc"
188+
git commit -m "Travis: add encrypted GPG signing keypair"
189+
fi
189190
else
190191
warn "No $signingKeySourceFile found. Travis will not be able to do GPG signing!"
191192
fi
@@ -198,7 +199,7 @@ test -d "$credentialsDir" ||
198199
"Please contact a SciJava administrator to receive a copy of this content."
199200

200201
# check prerequisites
201-
check git sed perl xmllint travis
202+
check git sed cut perl xmllint travis
202203

203204
# parse arguments
204205
EXEC=:

0 commit comments

Comments
 (0)