Android Pipeline files
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
version: 2 | |
references: | |
workspace: &workspace | |
~/lowcarb-android | |
config_android: &config_android | |
working_directory: *workspace | |
docker: | |
- image: circleci/android:api-28-alpha | |
environment: | |
TERM: dumb | |
JAVA_TOOL_OPTIONS: "-Xmx1g" | |
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=2 -Dkotlin.incremental=false" | |
CIRCLE_JDK_VERSION: oraclejdk8 | |
config_gcloud: &config_gcloud | |
working_directory: *workspace | |
docker: | |
- image: google/cloud-sdk:latest | |
environment: | |
TERM: dumb | |
cache_key: &cache_key | |
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }} | |
restore_cache: &restore_cache | |
restore_cache: | |
<<: *cache_key | |
save_cache: &save_cache | |
save_cache: | |
<<: *cache_key | |
paths: | |
- ~/.gradle/caches | |
- ~/.gradle/wrapper | |
persist_to_workspace: &persist_to_workspace | |
persist_to_workspace: | |
root: . | |
paths: | |
- ftl-tests | |
- build | |
- app/build | |
- distribution | |
- fastlane | |
- changelog.txt | |
- Gemfile | |
attach_workspace: &attach_workspace | |
attach_workspace: | |
at: *workspace | |
jobs: | |
build: | |
<<: *config_android | |
steps: | |
- checkout | |
- *restore_cache | |
- run: | |
name: Accept licenses | |
command: yes | sdkmanager --licenses || true | |
- run: | |
name: Decrypt release key | |
command: openssl aes-256-cbc -d -in distribution/release.keystore-cipher -out distribution/release.keystore -md sha256 -k $CIPHER_DECRYPT_KEY | |
- run: | |
name: Setup Firebase JSON configuration file | |
command: echo $FIREBASE_CONFIG_JSON | base64 -di > app/google-services.json | |
- run: | |
name: Run Linters | |
command: ./gradlew check detekt --stacktrace | |
- run: | |
name: Build | |
command: ./gradlew assemble bundleRelease assembleAndroidTest --stacktrace | |
- store_test_results: | |
path: app/build/test-results | |
- store_artifacts: | |
path: app/build/reports | |
destination: reports | |
- store_artifacts: | |
path: app/build/outputs/apk | |
destination: apks | |
- *save_cache | |
- *persist_to_workspace | |
test_instrumented: | |
<<: *config_gcloud | |
steps: | |
- *attach_workspace | |
- run: | |
name: Setup Google Cloud auth | |
command: ftl-tests/setup.sh | |
- run: | |
name: Run tests on Firebase Test Lab | |
command: ftl-tests/run-tests.sh | |
- run: | |
name: Download results | |
command: ftl-tests/download-results.sh firebase_test_results | |
when: always | |
- store_artifacts: | |
path: firebase_test_results | |
- store_test_results: | |
path: firebase_test_results | |
google_play_upload: | |
<<: *config_android | |
steps: | |
- *attach_workspace | |
- run: | |
name: Setup Google Play upload key | |
command: | | |
touch distribution/google-play-key.json | |
echo "${GOOGLE_PLAY_UPLOAD_KEY}" >> "distribution/google-play-key.json" | |
- run: | |
name: Setup Fastlane | |
command: gem install fastlane | |
- run: | |
name: Install JSON parser | |
command: sudo apt-get update && sudo apt-get install -y jq | |
- run: | |
name: Prepare changelog | |
command: | | |
mkdir "fastlane/metadata/android/pt-BR/changelogs" && touch "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" | |
mv changelog.txt "fastlane/metadata/android/pt-BR/changelogs/$(cat app/build/outputs/apk/release/output.json | jq -r '.[0].apkInfo.versionCode').txt" | |
- run: | |
name: Deploy to Google Play | |
command: bundle exec fastlane deploy | |
- run: | |
name: Update Changelog | |
command: bundle exec fastlane supply --skip_upload_apk true --skip_upload_aab true | |
workflows: | |
version: 2 | |
build_and_test: | |
jobs: | |
- build | |
- test_instrumented: | |
requires: | |
- build | |
- google_play_upload: | |
requires: | |
- test_instrumented |
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
#!/bin/sh | |
TEST_DIR=$1 | |
# Create directory for results | |
mkdir "$TEST_DIR" | |
# Pull down test results | |
gsutil -m cp -r -U "`gsutil ls gs://cloud-test-lowcarb-6eaa7 | tail -1`*" "$TEST_DIR" |
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
update_fastlane | |
default_platform(:android) | |
platform :android do | |
desc "Deploy a new version to the Google Play Internal track" | |
lane :deploy do | |
upload_to_play_store(track: 'internal', aab: 'app/build/outputs/bundle/release/app.aab', skip_upload_apk: true) | |
end | |
end |
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
#!/bin/sh | |
# Run tests on test lab | |
gcloud firebase test android run \ | |
--type instrumentation \ | |
--app app/build/outputs/apk/debug/app-debug.apk \ | |
--test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \ | |
--device model=Nexus6P,version=27,locale=en_US,orientation=portrait \ | |
--timeout 30m \ | |
--results-bucket cloud-test-lowcarb-6eaa7 \ | |
--no-record-video \ | |
--no-performance-metrics |
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
#!/bin/sh | |
if [ "$GCLOUD_SERVICE_KEY" = "" ]; then | |
echo "GCLOUD_SERVICE_KEY env variable is empty. Exiting." | |
exit 1 | |
fi | |
# Export to secrets file | |
echo $GCLOUD_SERVICE_KEY | base64 -di > client-secret.json | |
# Set project ID | |
gcloud config set project lowcarb-6eaa7 | |
# Auth account | |
gcloud auth activate-service-account lowcarb-ftl@lowcarb-6eaa7.iam.gserviceaccount.com --key-file client-secret.json | |
# Delete secret | |
rm client-secret.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Muito legal a tua palestra do TDC. Tenho muito interesse em fazer uma poc em um projeto demo.