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