如何在GitHub Actions CI/CD中构建Flutter [英] How to build Flutter in GitHub Actions CI/CD
问题描述
我正在尝试使用GitHub Actions构建我的Flutter应用程序,但是我不知道该从哪个容器映像中选择.
I'm trying out GitHub Actions to build my Flutter app but I don't know which container image to choose from.
是否有可用于Flutter的受信任的容器映像?
Is there a trusted container image that I can use for Flutter?
为了使Flutter SDK在构建步骤中可用,我需要进行哪些调整?
What are the adjustments I need to make so that the Flutter SDK is available during my build step?
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.
我修改了GitHub Actions生成的dart.yml
文件,如下所示:
I adapted the dart.yml
file generated by GitHub Actions to look like this:
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
推荐答案
You don't need to use a flutter specific container, there is a Flutter Action available that runs on the default Windows, Linux and macOS containers.
这意味着构建flutter应用程序就像使用动作(您还将需要Java动作)然后运行flutter build命令一样简单.以下示例运行aot构建:
This means that building your flutter app is as simple as using the action (you will also need the Java action) and then running the flutter build command. The following example runs an aot build:
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
我写了博客文章,内容涉及如果您想了解更多信息,可以使用动作来测试颤动.
I wrote a blog post about building and testing flutter using actions if you'd like to learn more.
这篇关于如何在GitHub Actions CI/CD中构建Flutter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!