forked from lyft/Kronos-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci
executable file
·61 lines (48 loc) · 1.89 KB
/
ci
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -euo pipefail
# You can run it from any directory.
PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$PROJECT_DIR" > /dev/null
# Export "PUBLISH_RELEASE=true" to initiate release process.
if [ "${PUBLISH_RELEASE:-}" != "true" ]; then
echo "Running non-release build...".
./gradlew --stacktrace build
else
echo "Launching release publishing process..."
if [ -z "${GPG_SECRET_KEYS:-}" ]; then
echo "Put base64 encoded gpg secret key for signing into GPG_SECRET_KEYS env variable."
exit 1
fi
if [ -z "${GPG_OWNERTRUST:-}" ]; then
echo "Put base64 encoded gpg ownertrust for signing into GPG_OWNERTRUST env variable."
exit 1
fi
if [ -z "${GPG_KEY_ID:-}" ]; then
echo "Put GPG key id into GPG_KEY_ID env variable."
exit 1
fi
if [ -z "${GPG_PASSPHRASE:-}" ]; then
echo "Put GPG passphrase into GPG_PASSPHRASE env variable."
exit 1
fi
set +e
echo "$GPG_SECRET_KEYS" | base64 --decode | gpg --import
gpg_import_result=$?
set -e
unset GPG_SECRET_KEYS
# Code '2' means that keys were already in local keychain.
if [ "$gpg_import_result" == "0" ] || [ "$gpg_import_result" == "2" ]; then
echo "GPG keys imported successfully."
else
echo "Failed to import GPG keys."
exit 1
fi
echo 'Importing GPG ownertrust...'
echo "$GPG_OWNERTRUST" | base64 --decode | gpg --import-ownertrust;
echo 'GPG ownertrust imported successfully.'
unset GPG_OWNERTRUST
./gradlew --stacktrace --info build publishToSonatype -Psigning.keyId="$GPG_KEY_ID" -Psigning.password="$GPG_PASSPHRASE" -Psigning.secretKeyRingFile="$HOME/.gnupg/secring.gpg"
unset GPG_PASSPHRASE
# Run closeAndReleaseRepository separately to avoid contention between publishing and closing.
./gradlew --stacktrace --info closeAndReleaseRepository
fi