Created
November 1, 2016 06:53
-
-
Save ralphpina/89ba0ebd942b487b53d187c0a808ff5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
machine: | |
environment: | |
TERM: "dumb" | |
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx5120m -XX:+HeapDumpOnOutOfMemoryError"' | |
ANDROID_HOME: /usr/local/android-sdk-linux | |
java: | |
version: | |
oraclejdk8 | |
dependencies: | |
pre: | |
- git config --global user.email "[email protected]" && git config --global user.name "Circle CI" | |
- sudo pip install -U crcmod | |
- cp -r android_license /usr/local/android-sdk-linux/licenses | |
# Android SDK Platform 24 | |
- if [ ! -d "/usr/local/android-sdk-linux/platforms/android-24" ]; then echo y | android update sdk --no-ui --all --filter "android-24"; fi | |
- if [ ! -d "/usr/local/android-sdk-linux/extras/google/google_play_services" ]; then echo y | android update sdk --no-ui --all --filter "extra-google-google_play_services"; fi | |
# Android SDK Build-tools, revision 24.0.1 | |
- if [ ! -d "/usr/local/android-sdk-linux/build-tools/24.0.2" ]; then echo y | android update sdk --no-ui --all --filter "build-tools-24.0.2"; fi | |
# Android Support Repository, revision 35 / Local Maven repository for Support Libraries | |
- if [ ! -d "/usr/local/android-sdk-linux/extras/android/m2repository/com/android/support/design/24.2.1" ]; then echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"; fi | |
cache_directories: | |
- /usr/local/android-sdk-linux/platforms/android-24 | |
- /usr/local/android-sdk-linux/build-tools/24.0.2 | |
- /usr/local/android-sdk-linux/extras/android/m2repository | |
- /usr/local/android-sdk-linux/extras/google/google_play_services | |
post: | |
- ./gradlew :mobile:assembleStagingDebug -PdisablePreDex | |
- ./gradlew :everstore:assembleDebugAndroidTest -PdisablePreDex | |
- ./gradlew :mobile:assembleStagingDebugAndroidTest -PdisablePreDex | |
- echo $CLIENT_SECRET | base64 --decode > ${HOME}/client-secret.json | |
- sudo /opt/google-cloud-sdk/bin/gcloud config set project everalbum-android | |
- sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update | |
- sudo /opt/google-cloud-sdk/bin/gcloud --quiet components install beta | |
- sudo /opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file ${HOME}/client-secret.json | |
test: | |
override: | |
- ./gradlew :mobile:lintProductionRelease | |
- ./gradlew :mobile:testStagingDebugUnitTest -PdisablePreDex | |
- echo "y" | sudo /opt/google-cloud-sdk/bin/gcloud beta test android run --type instrumentation --app mobile/build/outputs/apk/mobile-staging-debug.apk --test everstore/build/outputs/apk/everstore-debug-androidTest.apk --device-ids victara --os-version-ids 19 --orientations portrait --results-bucket everstore-cloud-test-circle-ctl-test | |
- echo "y" | sudo /opt/google-cloud-sdk/bin/gcloud beta test android run --type instrumentation --app mobile/build/outputs/apk/mobile-staging-debug.apk --test mobile/build/outputs/apk/mobile-staging-debug-androidTest.apk --device-ids victara --os-version-ids 19 --orientations portrait --results-bucket mobile-cloud-test-circle-ctl-test | |
post: | |
# copy lint results | |
- mv mobile/build/outputs/lint-results-productionRelease.xml $CIRCLE_TEST_REPORTS/MobileLint | |
# copy test results | |
- mv mobile/build/reports/tests/stagingDebug $CIRCLE_TEST_REPORTS/MobileUnitTests | |
# circleCi proper test value feature | |
- mkdir $CIRCLE_TEST_REPORTS/junit | |
- find */build/test-results -name "*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; | |
- sudo /opt/google-cloud-sdk/bin/gsutil -m cp -r -U `sudo /opt/google-cloud-sdk/bin/gsutil ls gs://everstore-cloud-test-circle-ctl-test | tail -1` $CIRCLE_ARTIFACTS/ | true | |
- sudo /opt/google-cloud-sdk/bin/gsutil -m cp -r -U `sudo /opt/google-cloud-sdk/bin/gsutil ls gs://mobile-cloud-test-circle-ctl-test | tail -1` $CIRCLE_ARTIFACTS/ | true | |
deployment: | |
production: | |
branch: master | |
commands: | |
# Increment version | |
- ./gradlew incrementVersion | |
# assemble flavors | |
- ./gradlew assembleStagingRelease assembleBetaRelease assembleProductionRelease | |
# upload to Fabric Beta | |
- ./gradlew crashlyticsUploadDistributionStagingRelease crashlyticsUploadDistributionBetaRelease crashlyticsUploadDistributionProductionRelease | |
# make a directory and write release notes to it. | |
- sudo mkdir -p mobile/src/main/play/en-US && sudo cp play_store_release_notes.txt mobile/src/main/play/en-US/whatsnew.txt | |
# publish APK to the Play Store | |
- ./gradlew :mobile:publishApkProductionRelease | |
# delete previously created notes | |
- sudo rm -rf mobile/src/main/play | |
# export version var | |
- echo "export VERSION_NUMBER=`grep app_version= gradle.properties | awk '{split($0,a,\"=\") ; print a[2] }'`" >> ~/.bashrc | |
# export rollout percent var | |
- echo "export ROLLOUT_PERC=`grep 'userFraction' mobile/build.gradle | egrep -o '[0-9].[0-9]{1,}' | awk '{ VAR = $1*100} END {print VAR}'`" >> ~/.bashrc | |
# post to slack | |
- curl -X POST --data-urlencode "payload={\"text\":\"New Android Release v$VERSION_NUMBER in the Play Store at $ROLLOUT_PERC%.\n\n $(cat fabric_beta_release_notes.txt)\"}" <The Slack channel> | |
# bump version and push | |
- git commit -am "Bump to $VERSION_NUMBER [skip ci]" | |
- git push origin master | |
# create GitHub release | |
- echo "export API_JSON=\"{\"tag_name\":\"v$VERSION_NUMBER\",\"target_commitish\":\"master\",\"name\":\"v$VERSION_NUMBER\",\"body\":\"Release of version v$VERSION_NUMBER\",\"draft\":false,\"prerelease\":false}\"" >> ~/.bashrc | |
- curl --data "$GIT_HUB_RELEASE_JSON" https://api.github.com/repos/everalbum/android/releases?access_token=<some token> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment