tas*_*iac 37 continuous-integration android travis-ci
我一直在使用Travis CI来构建我的Android应用程序.我正在使用debug.keystore我推送到公共存储库的调试版本中对其进行签名
但我想构建发布版本并使用此gradle插件将其上传到Google Play商店.
此过程需要a keystore和p12证书文件.
虽然我可以将加密的环境变量添加到Travis CI,但我不知道存储这些文件的最佳方法.
问题1:这样做的最佳做法是什么?有人可以提供开源实现吗?(我找不到一个)
一种可能的实现:安全地存储用户名和密码作为环境变量.将文件存储在启用SSL的环境中,并使用这些用户名和密码通过简单的HTTP身份验证保护它们.curl在构建过程开始之前使用它们进行下载.
问题2这种实施是否有意义?它安全吗?
额外:这2篇博文是与此相关的很好的资料,但不幸的是,它们都没有回答这个问题.
http://stablekernel.com/blog/deploying-google-play-continuous-delivery-android-part-4/ https://www.bignerdranch.com/blog/continuous-delivery-for-android/
Jar*_*ows 27
我已经开始在这里实现我的解决方案(开源):https://github.com/NonameDev/MathApp
System.getenv("TRAVIS")检测到您的构建上特拉维斯运行.storeFile rootProject.file('release.keystore') - 将释放密钥保存在您自己的存储库中 - 特拉维斯将隐藏密码storePassword System.getenv("KEYSTORE_PASS") - 在travis上存储环境变量 - travis将隐藏输出keyAlias System.getenv("ALIAS_NAME") - 在travis上存储环境变量 - travis将隐藏输出keyPassword System.getenv("ALIAS_PASS") - 在travis上存储环境变量 - travis将隐藏输出System.getenv("SERVICE_EMAIL") - 在travis上存储环境变量 - travis将隐藏输出rootProject.file('play.p12') - 在本地存储证书 - travis将存储电子邮件服务帐户build.gradle:buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.github.triplet.gradle:play-publisher:1.1.0'
}
}
Run Code Online (Sandbox Code Playgroud)
build.gradle:apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId 'burrows.apps.mathapp'
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName '1.0'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfigs {
debug {
storeFile rootProject.file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
if (System.getenv("TRAVIS")) {
release {
storeFile rootProject.file('release.keystore')
storePassword System.getenv("KEYSTORE_PASS")
keyAlias System.getenv("ALIAS_NAME")
keyPassword System.getenv("ALIAS_PASS")
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
if (System.getenv("TRAVIS")) {
play {
serviceAccountEmail = System.getenv("SERVICE_EMAIL")
pk12File = rootProject.file('play.p12')
track = 'production' // or 'alpha' or 'beta' or 'production'
}
}
Run Code Online (Sandbox Code Playgroud)
你看到这个答案吗?他在"之前"和"之后"修改他的构建时发布了他的TravisCI构建的链接.
这是他的答案:
基本上他不得不跑 sudo pip install google-api-python-client
话虽如此,我在这里检查了github回购.
.travis.yml:language: android
android:
components:
- build-tools-21.1.2
- extra-android-m2repository
env:
global:
- secure: <removed>
- secure: <removed>
before_install:
- ci/decrypt_files
- ci/start_emulator
install:
- ./gradlew build
before_script:
- ci/wait_for_emulator
script:
- ./gradlew connectedAndroidTestMockDebug
after_success:
- ci/deploy_all
notifications:
email:
- <removed>
Run Code Online (Sandbox Code Playgroud)
资料来源: https ://github.com/mg6maciej/VielenGamesAndroidClient/blob/develop/.travis.yml
这是secure使用密钥的过程的一部分,密码用于TravisCI(安全地存储在TravisCI上).
before_install:
- ci/decrypt_files
- ci/start_emulator
Run Code Online (Sandbox Code Playgroud)
来源ci/decrypt_files:
#!/bin/bash
openssl aes-256-cbc -d -k "$file_password" -in app/gradle.properties.enc -out app/gradle.properties
openssl aes-256-cbc -d -k "$file_password" -in app/crashlytics.properties.enc -out app/crashlytics.properties
openssl aes-256-cbc -d -k "$file_password" -in ci/vielengames.keystore.enc -out ci/vielengames.keystore
openssl aes-256-cbc -d -k "$file_password" -in ci/key.p12.enc -out key.p12
Run Code Online (Sandbox Code Playgroud)
资料来源: https ://github.com/mg6maciej/VielenGamesAndroidClient/blob/develop/ci/decrypt_files
这是在哪里python和其他Google库被下载并用于部署应用程序Google Play.
after_success:
- ci/deploy_all
Run Code Online (Sandbox Code Playgroud)
来源ci/deploy_all:
#!/bin/bash
test "$TRAVIS_BRANCH" == "master" && ci/deploy_google_play
ci/deploy_testfairy
ci/deploy_crashlytics_beta
Run Code Online (Sandbox Code Playgroud)
来源ci/deploy_google_play:
#!/bin/bash
DIR=$(dirname $0)
sudo apt-get install python-openssl
sudo pip install google-api-python-client
python $DIR/basic_upload_apks.py com.vielengames $DIR/../app/build/outputs/apk/app-production-release.apk
python $DIR/basic_upload_apks.py com.vielengames.staging $DIR/../app/build/outputs/apk/app-staging-release.apk
Run Code Online (Sandbox Code Playgroud)
你的问题1:
我相信你必须拥有keystore和p12应用程序,但你可以安全地存储您的密码与TravisCI(见"$file_password"),就像上面的例子.
你的问题2:
即使您拥有keystore和p12证书,您仍然需要密码(请参阅参考资料"$file_password")才能使用它们并用于发布到商店.
对于额外的安全性,您要添加另一个登录用更少的比你主要的登录权限.以下是回购的作者在这里做的事情:
...
TRACK = 'beta' # Can be 'alpha', beta', 'production' or 'rollout'
SERVICE_ACCOUNT_EMAIL = (
'148768954062-sp89pjb1blr7cu2f73f4fpd6dqloc047@developer.gserviceaccount.com')
# Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument('package_name',
help='The package name. Example: com.android.sample')
argparser.add_argument('apk_file',
nargs='?',
default='test.apk',
help='The path to the APK file to upload.')
...
Run Code Online (Sandbox Code Playgroud)
资料来源: https ://github.com/mg6maciej/VielenGamesAndroidClient/blob/develop/ci/basic_upload_apks.py
| 归档时间: |
|
| 查看次数: |
4905 次 |
| 最近记录: |