Skip to content

Commit 5b46e0a

Browse files
authored
Let Travis build the gallery and push to TestFlight / Play Store (flutter#14408)
* iOS works * Works on Android * Take in commit number in iOS also. Get rid of image upload for Android. It's just a waste of bandwidth * Tweak to fix on Travis
1 parent 9d302ac commit 5b46e0a

File tree

9 files changed

+107
-29
lines changed

9 files changed

+107
-29
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
os:
33
- linux
44
- osx
5+
osx_image: xcode9.2
56
env:
67
- SHARD=analyze
78
- SHARD=tests
89
- SHARD=docs
10+
- SHARD=build_and_deploy_gallery
911
matrix:
1012
exclude:
1113
- os: osx
1214
env: SHARD=analyze
1315
- os: osx
1416
env: SHARD=docs
17+
# TODO(xster): remove this when we know it works on Travis.
18+
allow_failures:
19+
- env: SHARD=build_and_deploy_gallery
1520
sudo: false
1621
filter_secrets: false
1722

@@ -22,6 +27,7 @@ addons:
2227
sources:
2328
- ubuntu-toolchain-r-test # if we don't specify this, the libstdc++6 we get is the wrong version
2429
packages:
30+
- lib32stdc++6
2531
- libstdc++6
2632
- fonts-droid
2733
language: node_js
@@ -31,6 +37,7 @@ git:
3137
# We rely on git tags for determining the version.
3238
depth: false
3339
cache:
40+
bundler: true
3441
directories:
3542
- $HOME/.pub-cache
3643
install:
@@ -41,4 +48,4 @@ before_script:
4148
- ./dev/bots/travis_setup.sh
4249
script:
4350
- ulimit -S -n 2048 # https://github.com/flutter/flutter/issues/2976
44-
- (./bin/cache/dart-sdk/bin/dart ./dev/bots/test.dart && ./dev/bots/travis_upload.sh)
51+
- ./dev/bots/travis_script.sh

dev/bots/travis_install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ set -ex
33

44
if [ -n "$TRAVIS" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
55
gem install coveralls-lcov
6+
gem install bundler
67
npm install -g firebase-tools@">=3.6.1 <3.7.0"
78
fi

dev/bots/travis_script.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
export PATH="$PWD/bin:$PWD/bin/cache/dart-sdk/bin:$PATH"
6+
7+
if [ "$SHARD" = "build_and_deploy_gallery" ]; then
8+
echo "Building and deploying Flutter Gallery"
9+
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
10+
echo "Building Flutter Gallery for Android..."
11+
export ANDROID_HOME=`pwd`/android-sdk
12+
(cd examples/flutter_gallery; flutter build apk --release)
13+
echo "Android Flutter Gallery built"
14+
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then # TODO(xster): add back && [ "$TRAVIS_BRANCH" = "dev" ] after testing
15+
echo "Deploying to Play Store..."
16+
(cd examples/flutter_gallery/android; bundle exec fastlane deploy_play_store)
17+
else
18+
echo "Flutter Gallery is only deployed to the Play Store on merged dev branch commits"
19+
fi
20+
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
21+
echo "Building Flutter Gallery for iOS..."
22+
(cd examples/flutter_gallery; flutter build ios --release --no-codesign)
23+
echo "iOS Flutter Gallery built"
24+
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then # TODO(xster): add back && [ "$TRAVIS_BRANCH" = "dev" ] after testing
25+
echo "Re-building with distribution profile and deploying to TestFlight..."
26+
(cd examples/flutter_gallery/ios; bundle exec fastlane build_and_deploy_testflight)
27+
else
28+
echo "Flutter Gallery is only deployed to the TestFlight on merged dev branch commits"
29+
fi
30+
fi
31+
elif [ "$SHARD" = "docs" ]; then
32+
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
33+
# Generate the API docs, upload them
34+
./dev/bots/docs.sh
35+
fi
36+
else
37+
dart ./dev/bots/test.dart
38+
fi

dev/bots/travis_setup.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@ if [ -n "$TRAVIS" ]; then
1010
echo "Installing Google Cloud SDK..."
1111
curl https://sdk.cloud.google.com | bash > /dev/null
1212
echo "Google Cloud SDK installation completed."
13+
14+
if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$SHARD" = "build_and_deploy_gallery" ]; then
15+
# Background for not using Travis's built-in Android tags
16+
# https://github.com/flutter/plugins/pull/145
17+
# Copied from https://github.com/flutter/plugins/blame/master/.travis.yml
18+
wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
19+
mkdir android-sdk
20+
unzip -qq sdk-tools-linux-3859397.zip -d android-sdk
21+
export ANDROID_HOME=`pwd`/android-sdk
22+
export PATH=`pwd`/android-sdk/tools/bin:$PATH
23+
mkdir -p /home/travis/.android # silence sdkmanager warning
24+
echo 'count=0' > /home/travis/.android/repositories.cfg # silence sdkmanager warning
25+
# suppressing output of sdkmanager to keep log under 4MB (travis limit)
26+
echo y | sdkmanager "tools" >/dev/null
27+
echo y | sdkmanager "platform-tools" >/dev/null
28+
echo y | sdkmanager "build-tools;26.0.3" >/dev/null
29+
echo y | sdkmanager "platforms;android-26" >/dev/null
30+
echo y | sdkmanager "extras;android;m2repository" >/dev/null
31+
echo y | sdkmanager "extras;google;m2repository" >/dev/null
32+
echo y | sdkmanager "patcher;v4" >/dev/null
33+
sdkmanager --list
34+
wget http://services.gradle.org/distributions/gradle-4.1-bin.zip
35+
unzip -qq gradle-4.1-bin.zip
36+
export GRADLE_HOME=$PWD/gradle-4.1
37+
export PATH=$GRADLE_HOME/bin:$PATH
38+
gradle -v
39+
./bin/flutter doctor
40+
fi
1341
fi
1442

1543
# disable analytics on the bots and download Flutter dependencies

dev/bots/travis_upload.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/flutter_gallery/android/app/build.gradle

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ if (flutterRoot == null) {
1111
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
1212
}
1313

14+
def flutterVersion = file("$flutterRoot/version").text
15+
def flutterVersionComponents = flutterVersion.split(/[^0-9]+/)
16+
// Let the integer version code of xx.yy.zz-pre.nnn be xxyyzznnn.
17+
int flutterVersionCode = Math.min(flutterVersionComponents[0].toInteger(), 20) * 100000000
18+
flutterVersionCode += Math.min(flutterVersionComponents[1].toInteger(), 99) * 1000000
19+
flutterVersionCode += Math.min(flutterVersionComponents[2].toInteger(), 999) * 1000
20+
flutterVersionCode += Math.min(flutterVersionComponents[3]?.toInteger() ?: 0, 999)
21+
1422
apply plugin: 'com.android.application'
1523
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
1624

@@ -25,8 +33,9 @@ android {
2533
applicationId "io.flutter.demo.gallery"
2634
minSdkVersion 16
2735
targetSdkVersion 27
28-
versionCode 1
29-
versionName "0.0.1"
36+
// The Gallery app's version is defined by the Flutter framework's version.
37+
versionCode flutterVersionCode
38+
versionName "$flutterVersion"
3039
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3140
}
3241

examples/flutter_gallery/android/fastlane/Fastfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ default_platform(:android)
77
# flutter build apk --release
88
# to build the app using the Flutter toolchain.
99
platform :android do
10-
desc 'Push the built release APK to alpha'
11-
lane :deploy_play_store_alpha do
10+
desc 'Push the built release APK to alpha or beta depending on current branch'
11+
lane :deploy_play_store do
1212
upload_to_play_store(
13-
track: 'alpha',
13+
track: ENV['TRAVIS_BRANCH'] == 'beta' ? 'beta' : 'alpha',
1414
apk: '../build/app/outputs/apk/release/app-release.apk',
1515
json_key_data: ENV['GOOGLE_DEVELOPER_SERVICE_ACCOUNT_ACTOR_FASTLANE'],
16-
skip_upload_screenshots: true
16+
skip_upload_screenshots: true,
17+
skip_upload_images: true
1718
)
1819
end
1920
end
-3.3 KB
Binary file not shown.

examples/flutter_gallery/ios/fastlane/Fastfile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ default_platform(:ios)
1010
# 1- Signing using the publishing credentials; and
1111
# 2- xcodebuild with archive option
1212
platform :ios do
13-
desc "Push a new release to TestFlight"
13+
desc 'Push a new release to TestFlight'
1414
lane :build_and_deploy_testflight do
1515
# Doesn't do anything when not on Travis.
1616
setup_travis
1717

18+
increment_version_number(
19+
# Relative to this file. Accept only digits and dots.
20+
version_number: File.read('../../../../version').gsub(/[^0-9\.]/, '')
21+
)
22+
1823
# Retrieves all the necessary certs and provisioning profiles.
1924
sync_code_signing(
20-
git_url: ENV["PUBLISHING_MATCH_CERTIFICATE_REPO"],
21-
type: "appstore",
25+
git_url: ENV['PUBLISHING_MATCH_CERTIFICATE_REPO'],
26+
type: 'appstore',
2227
readonly: true
2328
)
2429

@@ -27,19 +32,19 @@ platform :ios do
2732
# then run session.
2833
disable_automatic_code_signing
2934
update_project_provisioning(
30-
xcodeproj: "Runner.xcodeproj",
31-
target_filter: "Runner",
32-
build_configuration: "Release",
33-
profile: ENV["sigh_io.flutter.demo.gallery_appstore_profile-path"],
35+
xcodeproj: 'Runner.xcodeproj',
36+
target_filter: 'Runner',
37+
build_configuration: 'Release',
38+
profile: ENV['sigh_io.flutter.demo.gallery_appstore_profile-path'],
3439
)
3540

3641
# Build and archive the app again.
3742
build_ios_app(
38-
workspace: "Runner.xcworkspace",
39-
scheme: "Runner",
40-
export_method: "app-store",
43+
workspace: 'Runner.xcworkspace',
44+
scheme: 'Runner',
45+
export_method: 'app-store',
4146
# Verify that the right signing identity is used for publishing.
42-
codesigning_identity: "iPhone Distribution: Store Ladd (S8QB4VV633)",
47+
codesigning_identity: 'iPhone Distribution: Store Ladd (S8QB4VV633)',
4348
)
4449

4550
upload_to_testflight

0 commit comments

Comments
 (0)