From 1ae6cb955de3235bacde39495706cd73d3856854 Mon Sep 17 00:00:00 2001 From: Jumpei Matsuda Date: Thu, 27 Sep 2018 11:36:27 +0900 Subject: [PATCH] - Generate materials even on tag-push - Use utility functions on bash --- .circleci/bash.source | 12 ++++++++++++ .circleci/config.yml | 15 ++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 .circleci/bash.source diff --git a/.circleci/bash.source b/.circleci/bash.source new file mode 100644 index 00000000..842b7632 --- /dev/null +++ b/.circleci/bash.source @@ -0,0 +1,12 @@ +is_on_master_or_release() { + [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]] +} +should_be_release() { + deploy_to_google_play || is_on_master_or_release +} +deploy_to_deploygate() { + is_on_master_or_release +} +deploy_to_google_play() { + [[ "${CIRCLE_TAG:-undefined}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] +} diff --git a/.circleci/config.yml b/.circleci/config.yml index 19151a08..cb57e999 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,6 +9,7 @@ jobs: GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-Xmx1536m -XX:+HeapDumpOnOutOfMemoryError"' steps: - checkout + - run: echo "source $(git rev-parse --show-toplevel)/.circleci/bash.source" >> $BASH_ENV - restore_cache: key: jars-{{ checksum "build.gradle.kts" }}-{{ checksum "app/build.gradle.kts" }} - restore_cache: @@ -30,19 +31,19 @@ jobs: - run: name: decrypt keystore command: | - if [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]]; then + if should_be_release; then openssl aes-256-cbc -k $KEYSTORE_DECRYPT_PASSWORD -d -in encrypted-droidkaigi-key -out release.keystore -md sha256 fi - run: name: decrypt json command: | - if [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]]; then + if should_be_release; then openssl aes-256-cbc -k $JSON_DECRYPT_PASSWORD -d -in encrypted-google-services.json -out app/google-services.json -md sha256 fi - run: name: Test command: | - if [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]]; then + if should_be_release; then ./gradlew --stacktrace testRelease else ./gradlew --stacktrace test${APP_BUILD_TYPE^} @@ -50,7 +51,7 @@ jobs: - run: name: Build command: | - if [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]]; then + if should_be_release; then ./gradlew --offline --stacktrace assembleRelease else ./gradlew --offline --stacktrace assemble${APP_BUILD_TYPE^} @@ -58,7 +59,7 @@ jobs: - run: name: Check command: | - if [[ ! "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]]; then + if ! is_on_master_or_release; then ./gradlew --stacktrace lint${APP_BUILD_TYPE^} ./gradlew --stacktrace ktlint${APP_BUILD_TYPE^}Check bundle exec danger @@ -66,9 +67,9 @@ jobs: - run: name: Deploy command: | - if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' ]]; then + if deploy_to_deploygate; then ./gradlew :app:uploadDeployGateRelease - elif [[ "${CIRCLE_TAG:-undefined}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + elif deploy_to_google_play; then echo "Deploy to Google Play" openssl aes-256-cbc -k $PUBLISHER_KEYS_JSON_DECRYPT_PASSWORD -d -in encrypted-publisher-keys.json -out app/publisher-keys.json -md md5 ./gradlew publishApkRelease