From d04685a3b50623f15586a77eee76f16777f87a8c Mon Sep 17 00:00:00 2001 From: HuanCheng65 <609486518@qq.com> Date: Sun, 6 Feb 2022 20:52:46 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=BF=81=E7=A7=BB=E8=87=B3=20App=20Ce?= =?UTF-8?q?nter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .circleci/config.yml | 81 ------------------------------------------ app/build.gradle | 6 ++-- appcenter-pre-build.sh | 7 ++++ 3 files changed, 10 insertions(+), 84 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 appcenter-pre-build.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index cca96213..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,81 +0,0 @@ -version: 2.1 - -orbs: - app-center: rakutentech/app-center@0.1.3 - -jobs: - build: - working_directory: ~/code - - docker: - - image: circleci/android:api-30-ndk - - environment: - JVM_OPTS: -Xmx4G - - steps: - - checkout - - run: - name: Create release.keystore.jks - command: openssl aes-256-cbc -d -in "${releaseKeyStore}.encrypted" -k $RELEASE_ENCRYPT_SECRET_KEY -md md5 >> $releaseKeyStore - - run: - name: Create keystore.properies - command: printf 'releaseKeyAlias=%s\nreleaseKeyPassword=%s\nreleaseKeyStore=%s\nreleaseStorePassword=%s' $releaseKeyAlias $releaseKeyPassword $releaseKeyStore $releaseStorePassword > keystore.properties - - restore_cache: - key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - - run: - name: Fix 'Permission denied' - command: chmod +x ./gradlew - - run: - name: Download Dependencies - command: ./gradlew androidDependencies - - save_cache: - paths: - - ~/.gradle - key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - - run: - name: Initial build - command: ./gradlew clean assembleRelease --no-daemon --stacktrace - - store_artifacts: - path: app/build/outputs/apk/release/ - destination: apk/ - - store_artifacts: - path: app/build/outputs/mapping/release/ - destination: mapping/ - - run: - name: Define Environment Variable at Runtime - command: | - echo "export APP_VERSION_NAME=\$(cat ./app/build/outputs/apk/release/output-metadata.json | jq '.elements[0].versionName' | awk -F '\"' '{print \$2}')" >> $BASH_ENV - echo "export APP_OUTPUT_FILE=\$(cat ./app/build/outputs/apk/release/output-metadata.json | jq '.elements[0].outputFile' | awk -F '\"' '{print \$2}')" >> $BASH_ENV - echo "export APP_VERSION_CODE=\$(cat ./app/build/outputs/apk/release/output-metadata.json | jq '.elements[0].versionCode'" >> $BASH_ENV - source $BASH_ENV - -workflows: - version: 2 - build_and_upload: - jobs: - - build - - app-center/publish: - working_directory: ~/code/app/build/outputs/apk/release - name: Publish to App Center - group: HuanCheng65 - file: $APP_OUTPUT_FILE - app: TiebaLite - token: $APP_CENTER_TOKEN - notes: $APP_VERSION_NAME - - app-center/mapping: - working_directory: ~/code/app/build/outputs/mapping/release - name: Upload to App Center - file: mapping.txt - app: TiebaLite - token: $APP_CENTER_TOKEN - version-name: $APP_VERSION_NAME - version-code: $APP_VERSION_CODE - -workflows: - version: 2 - build_and_upload: - jobs: - - build - - upload_apk - - upload_mapping diff --git a/app/build.gradle b/app/build.gradle index dc680426..c184ded8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,12 +8,12 @@ def keystoreProperties = new Properties() keystoreProperties.load(new FileInputStream(rootProject.file("keystore.properties"))) def applicationProperties = new Properties() applicationProperties.load(new FileInputStream(rootProject.file("application.properties"))) -def SHA1 = System.getenv("CIRCLE_SHA1") +def buildId = System.getenv("APPCENTER_BUILD_ID") def applicationVersionCode = applicationProperties["versionCode"].toInteger() def applicationVersionName = applicationProperties["versionName"] def isPerVersion = applicationProperties["isPerRelease"] == "true" -if (SHA1 != null) { - applicationVersionName = applicationVersionName + ".${SHA1.substring(0, 7)}" +if (buildId != null) { + applicationVersionName = applicationVersionName + ".${buildId.substring(0, 7)}" } if (isPerVersion) { applicationVersionName = applicationVersionName + ".${applicationProperties["preReleaseName"]}-${applicationProperties["preReleaseVer"]}" diff --git a/appcenter-pre-build.sh b/appcenter-pre-build.sh new file mode 100644 index 00000000..97600ea2 --- /dev/null +++ b/appcenter-pre-build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +openssl aes-256-cbc -d -in "${releaseKeyStore}.encrypted" -k $RELEASE_ENCRYPT_SECRET_KEY -md md5 >> $releaseKeyStore + +printf 'releaseKeyAlias=%s\nreleaseKeyPassword=%s\nreleaseKeyStore=%s\nreleaseStorePassword=%s' $releaseKeyAlias $releaseKeyPassword $releaseKeyStore $releaseStorePassword > keystore.properties + +chmod +x ./gradlew \ No newline at end of file