-
Notifications
You must be signed in to change notification settings - Fork 71
/
signing.gradle
97 lines (92 loc) · 3.86 KB
/
signing.gradle
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
/*
* Firetweet - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
apply plugin: 'com.android.application'
/**
* Gradle script for signing applications
* Just apply this script to your application build.gradle file.
* DON'T FORGET TO IGNORE signing.properties FROM YOUR VERSION CONTROL!!!
*
* @author Mariotaku Lee <[email protected]>
*/
android {
signingConfigs {
debug {
File signingPropFile = rootProject.file('signing.properties')
if (signingPropFile.exists()) {
Properties signingProp = new Properties()
signingProp.load(signingPropFile.newDataInputStream())
storeFile file(signingProp.get("debug.storeFile"))
storePassword signingProp.get("debug.storePassword")
keyAlias signingProp.get("debug.keyAlias")
keyPassword signingProp.get("debug.keyPassword")
} else if (System.getenv('DEBUG_KEYSTORE_BASE64') != null) {
storeFile decodeKeyStoreFileFromBase64Env('DEBUG_KEYSTORE_BASE64')
storePassword System.getenv('DEBUG_KEYSTORE_PASSWORD')
keyAlias System.getenv('DEBUG_KEYSTORE_KEY_ALIAS')
keyPassword System.getenv('DEBUG_KEYSTORE_KEY_PASSWORD')
}
}
release {
File signingPropFile = rootProject.file('signing.properties')
if (signingPropFile.exists()) {
Properties signingProp = new Properties()
signingProp.load(signingPropFile.newDataInputStream())
storeFile file(signingProp.get("release.storeFile"))
storePassword signingProp.get("release.storePassword")
keyAlias signingProp.get("release.keyAlias")
keyPassword signingProp.get("release.keyPassword")
} else if (System.getenv('RELEASE_KEYSTORE_BASE64') != null) {
storeFile decodeKeyStoreFileFromBase64Env('RELEASE_KEYSTORE_BASE64')
storePassword System.getenv('RELEASE_KEYSTORE_PASSWORD')
keyAlias System.getenv('RELEASE_KEYSTORE_KEY_ALIAS')
keyPassword System.getenv('RELEASE_KEYSTORE_KEY_PASSWORD')
}
}
}
buildTypes {
debug {
if (rootProject.file('signing.properties').exists()
|| System.getenv('DEBUG_KEYSTORE_BASE64') != null) {
signingConfig signingConfigs.debug
}
}
release {
if (rootProject.file('signing.properties').exists()
|| System.getenv('RELEASE_KEYSTORE_BASE64') != null) {
signingConfig signingConfigs.release
}
}
}
}
def decodeKeyStoreFileFromBase64Env(String name) {
String keyStoreBase64 = System.getenv(name)
if (keyStoreBase64 == null) return null
File tempKeyStoreFile = File.createTempFile("tmp_ks_", ".jks", File.createTempDir())
FileOutputStream fos = null
try {
fos = new FileOutputStream(tempKeyStoreFile)
fos.write(keyStoreBase64.decodeBase64())
fos.flush()
} finally {
if (fos != null) {
fos.close()
}
}
return tempKeyStoreFile
}