-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_credentials
More file actions
executable file
·113 lines (89 loc) · 3.1 KB
/
setup_credentials
File metadata and controls
executable file
·113 lines (89 loc) · 3.1 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env sh
set -eu # -o pipefail # Debian dash does not support -o pipefail
# This script creates the .env file.
MAIN_VAULT="Developer"
VAULT="spitfire"
if [ ! -f "settings.gradle.kts" ]; then
# Do not depend on root directory name, because it may change on CI. For
# example Cirrus CI sets it as "working-dir".
echo "Must be run from the project root, but pubspec.yaml does not exist in current directory $PWD"
ls -lah
exit 1
fi
if ! command -v op >/dev/null 2>&1; then
echo "op command (1Password) CLI is not installed"
exit 1
fi
if ! command -v jq >/dev/null 2>&1; then
echo "jq is not installed"
exit 1
fi
true >.env # Clear file
_export() {
name="${1:-}"
value="${2:-}"
echo "$name=$value" >>.env
}
_export APP_BUNDLE_ID "pl.baftek.spitfire"
_export APP_PACKAGE_NAME "pl.baftek.spitfire"
_export FIREBASE_PROJECT_NUMBER "op://$VAULT/Firebase/project number"
_export FIREBASE_APP_ID_IOS "op://$VAULT/Firebase/iOS app ID"
_export FIREBASE_APP_ID_ANDROID "op://$VAULT/Firebase/Android app ID"
android_keystore() {
keystore_properties="$PWD/android/keystore.properties"
keystore="$PWD/android/keystore.jks"
op document get \
--force \
--vault "$MAIN_VAULT" \
--out-file "$keystore" \
"Android keystore" >/dev/null
cat <<EOF >"$keystore_properties"
storeFile=$keystore
storePassword=$(op read "op://$MAIN_VAULT/Android Keystore/Keystore password")
keyAlias=BaftekKey_spitfire
keyPassword=$(op read "op://$MAIN_VAULT/Android Keystore/Password for key BaftekKey_spitfire")
EOF
echo "$keystore_properties"
}
google_service_accounts() {
# for Google Play Android Developer
GOOGLE_PLAY_JSON_KEY_PATH="$PWD/android/google_play_android_developer_sa_key.json"
op document get \
--force \
--vault "$MAIN_VAULT" \
--out-file "$GOOGLE_PLAY_JSON_KEY_PATH" \
"Google Play Android Developer service account key"
_export GOOGLE_PLAY_JSON_KEY_PATH "$GOOGLE_PLAY_JSON_KEY_PATH"
# for Firebase App Distribution
FIREBASE_JSON_KEY_PATH="$PWD/android/firebase_sa_key.json"
op read "op://$VAULT/Firebase/firebase_sa_key.json" \
--force \
--out-file "$FIREBASE_JSON_KEY_PATH"
_export FIREBASE_JSON_KEY_PATH "$FIREBASE_JSON_KEY_PATH"
}
fastlane_match() {
GITHUB_USERNAME="op://$VAULT/GitHub/username"
_export GITHUB_USERNAME "$GITHUB_USERNAME"
GITHUB_PAT="op://$VAULT/GitHub/PAT"
_export GITHUB_PAT "$GITHUB_PAT"
MATCH_PASSWORD="op://$MAIN_VAULT/Fastlane Match certificates/password"
_export MATCH_PASSWORD "$MATCH_PASSWORD"
}
app_store_connect() {
APP_STORE_CONNECT="App Store Connect API key"
APP_STORE_CONNECT_ISSUER_ID="op://$MAIN_VAULT/$APP_STORE_CONNECT/Issuer ID"
_export APP_STORE_CONNECT_ISSUER_ID "$APP_STORE_CONNECT_ISSUER_ID"
APP_STORE_CONNECT_KEY_ID="op://$MAIN_VAULT/$APP_STORE_CONNECT/Key ID"
_export APP_STORE_CONNECT_KEY_ID "$APP_STORE_CONNECT_KEY_ID"
APP_STORE_CONNECT_P8_KEY_PATH="$PWD/ios/app_store_connect_api_key.p8"
op document get \
--force \
--vault "$MAIN_VAULT" \
--out-file "$APP_STORE_CONNECT_P8_KEY_PATH" \
"$APP_STORE_CONNECT"
_export APP_STORE_CONNECT_P8_KEY_PATH "$APP_STORE_CONNECT_P8_KEY_PATH"
}
android_keystore
google_service_accounts
fastlane_match
app_store_connect