diff --git a/.gitignore b/.gitignore index 235ca84f2fdab1f8ab8ed0224f3ed27e7391b9fb..4a20bb42fd6df0e95d7bb92b89e1c91111702513 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,7 @@ local.properties # macOS clutter .DS_Store + +# Fastlane docs and logs +fastlane/README.md +fastlane/report.xml diff --git a/.travis.yml b/.travis.yml index d712657231ad1b1b76b702226e43906d1ae73ae8..d848e96f417689d31d44ae6cddc443ae93f34945 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,7 @@ before_script: - android list target script: +- bash travis/bump-versioncode.sh - ./gradlew build connectedCheck test jacocoTestReport - bash assets/store_descriptions/generate_and_validate.sh @@ -49,11 +50,7 @@ after_success: - bash <(curl -s https://codecov.io/bash) before_deploy: -- git config --local user.name "TravisCI" -- git config --local user.email "support@openhab.org" -- git add fastlane/* -- git commit -m "Update fastlane metadata" -#- git push origin :refs/heads/master +- bash travis/commit-version-and-metadata.sh - openssl aes-256-cbc -K $encrypted_903a93ed2309_key -iv $encrypted_903a93ed2309_iv -in keystore.enc -out keystore -d - cp $TRAVIS_BUILD_DIR/keystore $HOME diff --git a/assets/store_descriptions/generate_and_validate.sh b/assets/store_descriptions/generate_and_validate.sh old mode 100644 new mode 100755 diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 0000000000000000000000000000000000000000..f1cf48cfe34177922b6333dd6e3f81044c4ff497 --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1,2 @@ +json_key_file "" # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one +package_name "org.openhab.habdroid" diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000000000000000000000000000000000000..89d839f6a5baf9dadb6fc2cdec6f802617db5f4a --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,44 @@ +# Customize this file, documentation can be found here: +# https://docs.fastlane.tools/actions/ +# All available actions: https://docs.fastlane.tools/actions +# can also be listed using the `fastlane actions` command + +# Change the syntax highlighting to Ruby +# All lines starting with a # are ignored when running `fastlane` + +# If you want to automatically update fastlane if a new version is available: +# update_fastlane + +# This is the minimum version number required. +# Update this, if you use features of a newer version +fastlane_version "2.69.3" + +# Opt out of sending metrics and crash reports +opt_out_usage +opt_out_crash_reporting + +default_platform :android + +platform :android do + desc "Deploy a new version to the Google Play" + lane :deploy do + upload_to_play_store( + track: 'production', + apk: "$HOME/apks_to_deploy/openhab-android.apk" + ) + end + + desc "Deploy a new beta version to the Google Play" + lane :betaDeploy do + upload_to_play_store( + track: 'beta', + apk: "$HOME/apks_to_deploy/openhab-android.apk" + ) + end +end + +# More information about multiple platforms in fastlane: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform +# All available actions: https://docs.fastlane.tools/actions + +# fastlane reports which actions are used. No personal data is recorded. +# Learn more at https://docs.fastlane.tools/#metrics diff --git a/travis/bump-versioncode.sh b/travis/bump-versioncode.sh new file mode 100644 index 0000000000000000000000000000000000000000..e74d92c4e601f5ce73a1f0aac96580e7732ede55 --- /dev/null +++ b/travis/bump-versioncode.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -e + +if $(echo "$TRAVIS_TAG" | grep -q "fdroid") +then + echo "Tag for F-Droid detected. Nothing to do" + exit 1 +fi + +manifest="mobile/src/main/AndroidManifest.xml" + +currentVersionCode=$(grep 'android:versionCode' $manifest | sed -r 's/(.*)"(.*)"/\2/') +let currentVersionCode++ + +if [ -z "$TRAVIS_TAG" ] +then + TRAVIS_TAG=$(git rev-parse HEAD) + echo "Tag is empty, use git hash ($TRAVIS_TAG) instead" +fi + +if [ -z "$currentVersionCode" ] || [ -z "$TRAVIS_TAG" ] +then + echo "Code ($currentVersionCode) or tag ($TRAVIS_TAG) are empty! Don't bump anything." +else + echo "New version code is $currentVersionCode and name $TRAVIS_TAG" + echo "Replace versionCode" + sed --in-place -r "s/android:versionCode=\"(.*)\"/android:versionCode=\"${currentVersionCode}\"/" $manifest + echo "Replace versionName" + sed --in-place -r "s/android:versionName=\"(.*)\"/android:versionName=\"${TRAVIS_TAG}\"/" $manifest +fi diff --git a/travis/commit-version-and-metadata.sh b/travis/commit-version-and-metadata.sh new file mode 100644 index 0000000000000000000000000000000000000000..8b37f4c3d901db348cdb8ded5ebefb604f45b518 --- /dev/null +++ b/travis/commit-version-and-metadata.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +set -e + +manifest="mobile/src/main/AndroidManifest.xml" + +echo "Configure git" +git config --local user.name "TravisCI" +git config --local user.email "support@openhab.org" +echo "Git add" +git add fastlane/* +git add $manifest +echo "Git commit" +git commit -m "Bump version to $TRAVIS_TAG and update fastlane metadata" +echo "Git tag" +git tag -a "${TRAVIS_TAG}-fdroid" -m "${TRAVIS_TAG} for F-Droid" +echo "Git decrypt key" +openssl aes-256-cbc -K $encrypted_c0c05d762590_key -iv $encrypted_c0c05d762590_iv -in travis/key.enc -out travis/key -d > /dev/null 2>&1 +echo "Copy ssh config" +cp travis/ssh-config ~/.ssh/config +echo "Git add remote" +git remote add github git@github.com:openhab/openhab-android +echo "Git fetch" +git fetch github +echo "Git push" +git push --quiet --set-upstream github :refs/heads/master > /dev/null 2>&1 diff --git a/travis/key.enc b/travis/key.enc new file mode 100644 index 0000000000000000000000000000000000000000..f421899683c58fa2f1ef61a9254db93372405277 Binary files /dev/null and b/travis/key.enc differ diff --git a/travis/key.pub b/travis/key.pub new file mode 100644 index 0000000000000000000000000000000000000000..0b1babef70540896879220616418df3834c6d897 --- /dev/null +++ b/travis/key.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDGmbjX/U2Li5YdL9smiRif3LNs/PKVuobAZS7Zva0FuApZggVx/V+cvBDyJDJAjw33WHCp/gQ0FeMrYvpZltzwJh/8HcahuBXbp5JEMMZVYdg1vIjMJ4QuIiF512SPJLq974FB4VCcbWgSpnGiMnH/MtX4ETFkYsOz0d2jEgZDH/vl7inMrym/GNJoN7p/UON6aE03RcRbpLIjgxtUQLE1S33pNkUvJQY9bTcbeCxobGR/iSSThEoOJv6hZtF153UBoZIuK5SQFJvBz3DcQi7WAGQyZOa83Drz4iq6OcoO7V6gSxszMbSdeJfaaAw19jD/P2mS0I6MI3k+1sC5cwOJHrpTNbmsXLNn8N3OFDSPagxxLQn1zVTELHp+HvN4zMgLnskEZMavETAmizfYEvmCVKh+/sykf2L40z9ZyimUPVEvgJl4/MYeIjeYnMfwc0xC8txppSI3qkU9ljfe5j9L9nFzYtvE34T9pL3Dd4TuIN3hW0WLnuRHBb4yxaPk/xfCdhLhJI5xqKTE5Y6fXT41g1F+eAqHrd3NrySnkvzJJPmBpYJBj3dEX7rOXnZxw/5NG9cklRVPbS/mQ1zqoLrH6AeI5IcN0FZk8N3uoEpjZglgrtRGhos5OA4Bno5vjxNvVadHbmY6UBCNMIqpP3/nbfS2mMl50CK//jDiaH/++Q== travis diff --git a/travis/ssh-config b/travis/ssh-config new file mode 100644 index 0000000000000000000000000000000000000000..134ac8b5fd288fe11e2653dc02b5500eab2d285a --- /dev/null +++ b/travis/ssh-config @@ -0,0 +1,3 @@ +Host github.com + HostName github.com + IdentityFile /home/travis/build/openhab/openhab-android/travis/key