Android deployment using Fastlane but only on Tag push

Hi,

I’m new to Travis-ci and I got my Android deployment all setup without conditions. Now I want to make sure deployment only happens when a certain tag is pushed, but I can’t seem to figure out how this is suppose to work (no examples I could find and documentation isn’t very clear on it)? I’ve added my yml file below, can anyone help me out? Also, using this script deployment of a simple Android app takes ± 10 minutes. Is there a way to speed this up (maybe using a different docker image or something)?

language: android
sudo: required
jdk: oraclejdk8

env:
  global:
  - ANDROID_API_LEVEL=28
  - ANDROID_BUILD_TOOLS_VERSION=28.0.3
  - ANDROID_ABI=armeabi-v7a

android:
  components:
    - tools
    - platform-tools
    - tools
    - extra-android-m2repository
  licenses:
    - 'android-sdk-preview-license-52d11cd2'
    - 'android-sdk-license-.+'
    - 'google-gdk-license-.+'

before_install:
  - touch $HOME/.android/repositories.cfg
  - yes | sdkmanager "platforms;android-28"
  - yes | sdkmanager "build-tools;28.0.3"
  - cd Android/GitViewer
  - gem update --system
  - gem install fastlane --quiet
  - gem install travis-conditions
  - bundle install
  - bundle update

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
  directories:
  - $HOME/.gradle/caches/
  - $HOME/.gradle/wrapper/
  - $HOME/.android/build-cache

before_script:
  - cd $TRAVIS_BUILD_DIR/Android/GitViewer
  - chmod +x gradlew

script:
  -./gradlew dokka

deploy:
  # Deploy a Staging version when Fabric/Staging tag is pushed
  - provider: script
    script: bundle exec fastlane deploy_staging
    on:
      tags: true
      conditions: "$TRAVIS_TAG =~ (?:Fabric\/Staging)"

  # Deploy a Production version when Fabric/Production tag is pushed
  - provider: script
    script: bundle exec fastlane deploy_production
    on:
      tags: true
      conditions: "$TRAVIS_TAG =~ (?:Fabric\/Production)"

  # Deploy a Production version to the Google Play Store
  - provider: script
    script: bundle exec fastlane deploy_play_store
    on: 
      tags: true
      conditions: $TRAVIS_TAG =~ (?:GooglePlayStore)


# jobs:
#   include:
#     - stage: deploy_staging
#       script: bundle exec fastlane deploy_staging
#     - stage: deploy_production
#       script: bundle exec fastlane deploy_production
#     - stage: deploy_playstore
#       script: bundle exec fastlane deploy_play_store
    
# stages:
#   - name: deploy_staging
#     deploy:
#       on:
#         tags: true
#         condition: "$TRAVIS_TAG =~ (?:Fabric\/Staging)"
#   - name: deploy_production
#     deploy:
#       on:
#         tags: true
#         condition: "$TRAVIS_TAG =~ (?:Fabric\/Production)"
#   - name: deploy_playstore
#     deploy:
#       on:
#         tags: true
#         condition: "$TRAVIS_TAG =~ (?:Fabric\/Production)"

Actually I just figured out that the code above is working! But it’s not showing up on the Travis dashboard when it’s running. However I do get a slack notification that the build is succeeded and uploaded to Fabric.

Any idea why this is not showing up on the Travis dashboard as a running job?

When reporting problems, please include relevant build URLs. Thanks.

Hi BanzaiMan,

Sorry for the late reply, but what build URLs do you mean exactly? This is the Github URL i’m testing Travis-CI on:

I’ve also updated my travis script so iOS builds are also working (from the same repo) on the travisci branch

thx!

Like this, for example.

https://travis-ci.com/sping/guild-ci-test-projects/builds/129100263

Hi BanzaiMan,

Thx I know that now for the future when I need support! That build you linked too is not containing the “build only when tag is pushed” part. I can’t link to a specific build that does the “build only on tag push” because it doesn’t show up in the dashboard

Any build for your project must be present in either https://travis-ci.com/sping/guild-ci-test-projects/builds or https://travis-ci.com/sping/guild-ci-test-projects/pull_requests

Hi,

Well when I use the current .travis.yml file, and push a tag I get a slack notification that Fastlane made a build but I don’t see it on the Travis Dashboard anywhere. Maybe my travis.yml file is incorrect or something?

Thx!

Check https://travis-ci.com/sping/guild-ci-test-projects/requests

Imprint