From 7fe9c0f1069450decaab5ec3f6188d260196bc86 Mon Sep 17 00:00:00 2001 From: Jumpei Matsuda Date: Thu, 27 Sep 2018 10:48:05 +0900 Subject: [PATCH 1/3] Fixed bash syntax error --- .circleci/config.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ec6a31d9..dcfa60e2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,19 +30,19 @@ jobs: - run: name: decrypt keystore command: | - if [ $CIRCLE_BRANCH = 'master' -o $CIRCLE_BRANCH = 'release' ]; then + if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then openssl aes-256-cbc -k $KEYSTORE_DECRYPT_PASSWORD -d -in encrypted-droidkaigi-key -out release.keystore fi - run: name: decrypt json command: | - if [ $CIRCLE_BRANCH = 'master' -o $CIRCLE_BRANCH = 'release' ]; then + if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then openssl aes-256-cbc -k $JSON_DECRYPT_PASSWORD -d -in encrypted-google-services.json -out app/google-services.json fi - run: name: Test command: | - if [ $CIRCLE_BRANCH = 'master' -o $CIRCLE_BRANCH = 'release' ]; then + if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then ./gradlew --stacktrace testRelease else ./gradlew --stacktrace test${APP_BUILD_TYPE^} @@ -50,7 +50,7 @@ jobs: - run: name: Build command: | - if [ $CIRCLE_BRANCH = 'master' -o $CIRCLE_BRANCH = 'release' ]; then + if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then ./gradlew --offline --stacktrace assembleRelease else ./gradlew --offline --stacktrace assemble${APP_BUILD_TYPE^} @@ -58,7 +58,7 @@ jobs: - run: name: Check command: | - if [ ! $CIRCLE_BRANCH = 'master' -a ! $CIRCLE_BRANCH = 'release' ]; then + if [[ "${CIRCLE_BRANCH:-undefined}" != 'master' -a "${CIRCLE_BRANCH:-undefined}" != 'release' ]]; then ./gradlew --stacktrace lint${APP_BUILD_TYPE^} ./gradlew --stacktrace ktlint${APP_BUILD_TYPE^}Check bundle exec danger @@ -66,9 +66,9 @@ jobs: - run: name: Deploy command: | - if [ $CIRCLE_BRANCH = 'master' ]; then + if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' ]]; then ./gradlew :app:uploadDeployGateRelease - elif [[ "${CIRCLE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + elif [[ "${CIRCLE_TAG:-undefined}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; 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 ./gradlew publishApkRelease From f6db45330097c625410e0297c35260cd465127d6 Mon Sep 17 00:00:00 2001 From: Jumpei Matsuda Date: Thu, 27 Sep 2018 10:48:56 +0900 Subject: [PATCH 2/3] Specify cipher of each encrypted materials --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dcfa60e2..aca7b2ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,13 +31,13 @@ jobs: name: decrypt keystore command: | if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then - openssl aes-256-cbc -k $KEYSTORE_DECRYPT_PASSWORD -d -in encrypted-droidkaigi-key -out release.keystore + 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' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then - openssl aes-256-cbc -k $JSON_DECRYPT_PASSWORD -d -in encrypted-google-services.json -out app/google-services.json + 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 @@ -70,7 +70,7 @@ jobs: ./gradlew :app:uploadDeployGateRelease elif [[ "${CIRCLE_TAG:-undefined}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; 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 + 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 fi - store_artifacts: From ace848463d9fd4896d20552f06dd4e56168932d3 Mon Sep 17 00:00:00 2001 From: Jumpei Matsuda Date: Thu, 27 Sep 2018 11:09:56 +0900 Subject: [PATCH 3/3] Use regexp match --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aca7b2ae..19151a08 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,19 +30,19 @@ jobs: - run: name: decrypt keystore command: | - if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then + if [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|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' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then + if [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|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' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then + if [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]]; then ./gradlew --stacktrace testRelease else ./gradlew --stacktrace test${APP_BUILD_TYPE^} @@ -50,7 +50,7 @@ jobs: - run: name: Build command: | - if [[ "${CIRCLE_BRANCH:-undefined}" == 'master' -o "${CIRCLE_BRANCH:-undefined}" == 'release' ]]; then + if [[ "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]]; then ./gradlew --offline --stacktrace assembleRelease else ./gradlew --offline --stacktrace assemble${APP_BUILD_TYPE^} @@ -58,7 +58,7 @@ jobs: - run: name: Check command: | - if [[ "${CIRCLE_BRANCH:-undefined}" != 'master' -a "${CIRCLE_BRANCH:-undefined}" != 'release' ]]; then + if [[ ! "${CIRCLE_BRANCH:-undefined}" =~ ^(master|release)$ ]]; then ./gradlew --stacktrace lint${APP_BUILD_TYPE^} ./gradlew --stacktrace ktlint${APP_BUILD_TYPE^}Check bundle exec danger