GitHub 发布了可以直接集成在 GitHub 仓库的 CI/CD 工具, GitHub Actions。而且针对 Public 项目免费提供。java
我尝试了在 Flutter 项目上使用,相比 travis-ci,目前看来除了方便(不用跳出 github 站外), 尚未其余优势发现。git
使用的已有的 Action: github.com/subosito/fl…github
.github/workflows/check.ymlmacos
name: F4LabCI
on: pull_request
jobs:
check:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: "12.x"
- uses: subosito/flutter-action@v1
with:
# same with pubspec.yaml
flutter-version: "1.9.1+hotfix.2"
- run: flutter pub get
- run: flutter test --no-pub test/
复制代码
release-v*
tag 时触发打包, 并上传到 release.github/workflows/release.ymlubuntu
name: F4LabCIRelease
on:
push:
tags:
- "release-v*"
jobs:
release-to-gitHub:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: "12.x"
- uses: subosito/flutter-action@v1
with:
# same with pubspec.yaml
flutter-version: "1.9.1+hotfix.2"
- run: flutter pub get
- run: flutter analyze --no-pub --no-current-package lib/ test/
- run: flutter test --no-pub test/
- run: flutter build apk
- uses: softprops/action-gh-release@v1
with:
files: build/app/outputs/apk/release/app-release.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
复制代码