Flutter Travis CI

Install Android SDK

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
os: linux

language: android

licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+

android:
components:
- tools
- platform-tools
- build-tools-28.0.3
- android-28 # match your targetVersion

jdk: oraclejdk8

sudo: false

addons:
apt:
# Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++6
- fonts-droid

Install Flutter

1
2
3
4
5
6
7
8
9
cache:
directories:
- "$HOME/.pub-cache"


install:
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
- export PATH=./flutter/bin:$PATH
- flutter doctor

Test & Analyze Flutter Code

1
2
3
4
script:
- flutter packages get
- flutter analyze --no-pub --no-current-package lib/ test/
- flutter test --no-pub test/

Push Release To GitHub

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
env:
- BUILD_TIME=$(date +'%Y%m%d%H%M%S') APK_NAME="${TRAVIS_TAG}_${BUILD_TIME}_F4Lab.apk"

before_deploy:
- flutter build apk
- mv build/app/outputs/apk/release/app-release.apk $APK_NAME

deploy:
provider: releases
api_key:
secure: $github_deploy_api_key
file: $APK_NAME
skip_cleanup: true
overwrite: true
on:
repo: stefanJi/Flutter4GitLab
branch: master
condition: $TRAVIS_TAG =~ /^release-v\d+\.\d+\.\d+/ # when tag match release-vx.x.x, then push a relase and upload apk.

Full Config

Flutter4GitLab/.travis.yml

赏杯咖啡 🍵 Donate