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 }}
複製代碼