forked from Digitaler-Impfnachweis/covpass-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign.sh
executable file
·44 lines (35 loc) · 1.32 KB
/
sign.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
38
39
40
41
42
43
44
#!/usr/bin/env bash
#
# (C) Copyright IBM Deutschland GmbH 2021
# (C) Copyright IBM Corp. 2021
#
set -eu -o pipefail
# Signs a bundle with the release key
APP="$1"
TYPE="${2:-release}"
if [[ -f "$APP" ]]; then
BUNDLE="$APP"
else
BUNDLE="$(ls "$APP/build/outputs/apk/${TYPE}"/*.apk | tail -1)"
fi
if [ -z "${RELEASE_KEYSTORE:-}" ]; then
1>&2 echo "RELEASE_KEYSTORE environment variable must be set"
exit 1
fi
if [ -z "${RELEASE_KEYSTORE_PASSWORD:-}" ]; then
1>&2 echo "RELEASE_KEYSTORE_PASSWORD environment variable must be set"
exit 1
fi
if [ -z "${RELEASE_KEYSTORE_KEY:-}" ]; then
1>&2 echo "RELEASE_KEYSTORE_KEY environment variable must be set"
exit 1
fi
if [ -z "${RELEASE_KEYSTORE_KEY_PASSWORD:-}" ]; then
1>&2 echo "RELEASE_KEYSTORE_KEY_PASSWORD environment variable must be set"
exit 1
fi
if [[ "$BUNDLE" == *.aab ]]; then
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -storetype pkcs12 -keystore "$RELEASE_KEYSTORE" -storepass "$RELEASE_KEYSTORE_PASSWORD" -keypass "$RELEASE_KEYSTORE_KEY_PASSWORD" "$BUNDLE" "$RELEASE_KEYSTORE_KEY"
else
java -jar /usr/lib/android-sdk/build-tools/debian/apksigner.jar sign --verbose --ks-type pkcs12 --ks "$RELEASE_KEYSTORE" --ks-pass "env:RELEASE_KEYSTORE_PASSWORD" --ks-key-alias "$RELEASE_KEYSTORE_KEY" --key-pass "env:RELEASE_KEYSTORE_KEY_PASSWORD" "$BUNDLE"
fi