小编典典

如何在GitHub Actions CI / CD中构建Flutter

flutter

我正在尝试使用GitHub Actions构建我的Flutter应用程序,但是我不知道要选择哪个容器映像。

是否有可用于Flutter的受信任的容器映像?

我需要进行哪些调整,才能在构建步骤中使用Flutter SDK?

Run flutter pub get


/__w/_temp/46389e95-36bc-464e-ab34-41715eb4dccb.sh: 1: /__w/_temp/46389e95-36bc-464e-ab34-41715eb4dccb.sh: flutter: not found
##[error]Process completed with exit code 127.

我修改了dart.ymlGitHub Actions生成的文件,使其看起来像这样:

name: Dart CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    container:
      image:  google/dart:latest

    steps:
    - uses: actions/checkout@v1
    - name: Install dependencies
      run: flutter pub get
    - name: Run tests
      run: flutter test

阅读 660

收藏
2020-08-13

共1个答案

小编典典

您无需使用特定于flutter的容器,可以使用Flutter
Action
在默认的Windows,Linux和macOS容器上运行。

这意味着构建flutter应用程序就像使用动作(您还将需要Java动作)然后运行flutter build命令一样简单。以下示例运行aot构建:

on: push
jobs: 
  build-and-test: 
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1 
    # The flutter action needs java so include it
    - uses: actions/setup-java@v1
      with:
        java-version: '12.x'
    # Include the flutter action
    - uses: subosito/flutter-action@v1
      with:
        channel: 'stable'  
    # Get flutter packages
    - run: flutter pub get
    # Build :D 
    - run: flutter build aot

如果您想了解更多信息,我写了一篇有关使用动作构建和测试抖动的博客文章

2020-08-13