从 EAS CLI 升级

了解如何升级你的开发和发布流程以使用 EAS 工作流。


如果你使用 EAS CLI 构建、提交和更新应用,则可以升级到 EAS Workflows 以自动化开发和发布流程。EAS 工作流可以构建、提交和更新你的应用,同时还可以运行其他作业,如 Maestro 测试、单元测试、自定义脚本等。

¥If you're using EAS CLI to build, submit, and update your app, you can upgrade to EAS Workflows to automate your development and release processes. EAS Workflows can build, submit, and update your app, while also running other jobs like Maestro tests, unit tests, custom scripts, and more.

下面你将找到如何设置项目以使用 EAS 工作流,然后是 EAS CLI 命令的常见示例以及如何将它们转换为 EAS 工作流。

¥Below you'll find how to set up your project to use EAS Workflows, followed by common examples of EAS CLI commands and how to convert them to EAS Workflows.

配置你的项目

¥Configure your project

EAS 工作流需要链接到你的 EAS 项目的 GitHub 存储库才能运行。你可以使用以下步骤将 GitHub 存储库链接到你的 EAS 项目:

¥EAS Workflows require a GitHub repository that's linked to your EAS project to run. You can link a GitHub repo to your EAS project with the following steps:

  • 导航到项目的 GitHub 设置

    ¥Navigate to your project's GitHub settings.

  • 按照 UI 安装 GitHub 应用。

    ¥Follow the UI to install the GitHub app.

  • 选择与 Expo 项目匹配的 GitHub 存储库并连接它。

    ¥Select the GitHub repository that matches the Expo project and connect it.

EAS 构建

¥EAS Build

你可以使用 EAS CLI 和 eas build 命令构建项目。要使用 production 构建配置文件进行 iOS 构建,你需要运行以下 EAS CLI 命令:

¥You can make a build of your project using EAS CLI with the eas build command. To make an iOS build with the production build profile, you'd run the following EAS CLI command:

Terminal
eas build --platform ios --profile production

要将其转换为工作流,请在项目根目录下创建一个名为 .eas/workflows/build-ios-production.yml 的工作流文件。

¥To convert this into a workflow, create a workflow file named .eas/workflows/build-ios-production.yml at the root of your project.

在 build-ios-production.yml 中,你可以使用以下工作流程启动使用 production 构建配置文件创建 iOS 构建的作业。

¥Inside build-ios-production.yml, you can use the following workflow to kick off a job that creates an iOS build with the production build profile.

.eas/workflows/build-ios-production.yml
name: iOS production build

on:
  push:
    branches: ['main']

jobs:
  build_ios:
    name: Build iOS
    type: build
    params:
      platform: ios
      profile: production

获得此工作流文件后,你可以通过将提交推送到 main 分支或运行以下命令来启动它:

¥Once you have this workflow file, you can kick it off by pushing a commit to the main branch, or by running the following command:

Terminal
eas workflow:run build-ios-production.yml

你可以提供参数来构建 Android 或使用其他构建配置文件。了解有关使用 构建作业文档 构建作业参数的更多信息。

¥You can provide parameters to make Android builds or use other build profiles. Learn more about build job parameters with the build job documentation.

EAS 提交

¥EAS Submit

你可以使用 EAS CLI 和 eas submit 命令将你的应用提交到应用商店。要提交 iOS 应用,你需要运行以下 EAS CLI 命令:

¥You can submit your app to the app stores using EAS CLI with the eas submit command. To submit an iOS app, you'd run the following EAS CLI command:

Terminal
eas submit --platform ios

要将其转换为工作流,请在项目根目录下创建一个名为 .eas/workflows/submit-ios.yml 的工作流文件。

¥To convert this into a workflow, create a workflow file named .eas/workflows/submit-ios.yml at the root of your project.

在 submit-ios.yml 中,你可以使用以下工作流程启动提交 iOS 应用的作业。

¥Inside submit-ios.yml, you can use the following workflow to kick off a job that submits an iOS app.

.eas/workflows/submit-ios.yml
name: Submit iOS app

on:
  push:
    branches: ['main']

jobs:
  submit_ios:
    name: Submit iOS
    type: submit
    params:
      platform: ios

获得此工作流文件后,你可以通过将提交推送到 main 分支或运行以下命令来启动它:

¥Once you have this workflow file, you can kick it off by pushing a commit to the main branch, or by running the following command:

Terminal
eas workflow:run submit-ios.yml

你可以提供参数来提交其他平台或使用其他提交配置文件。了解有关使用 提交作业文档 提交作业参数的更多信息。

¥You can provide parameters to submit other platforms or use other submit profiles. Learn more about submit job parameters with the submit job documentation.

EAS 更新

¥EAS Update

你可以使用 EAS CLI 和 eas update 命令更新你的应用。要更新你的应用,你需要运行以下 EAS CLI 命令:

¥You can update your app using EAS CLI with the eas update command. To update your app, you'd run the following EAS CLI command:

Terminal
eas update --auto

要将其转换为工作流,请在项目根目录下创建一个名为 .eas/workflows/publish-update.yml 的工作流文件。

¥To convert this into a workflow, create a workflow file named .eas/workflows/publish-update.yml at the root of your project.

在 publish-update.yml 中,你可以使用以下工作流程启动发送无线更新的作业。

¥Inside publish-update.yml, you can use the following workflow to kick off a job that sends and over-the-air update.

.eas/workflows/publish-update.yml
name: Publish update

on:
  push:
    branches: ['*']

jobs:
  update:
    name: Update
    type: update
    params:
      branch: ${{ github.ref_name || 'test'}}

获得此工作流文件后,你可以通过将提交推送到任何分支或运行以下命令来启动它:

¥Once you have this workflow file, you can kick it off by pushing a commit to any branch, or by running the following command:

Terminal
eas workflow:run publish-update.yml

你可以提供参数来更新特定分支或渠道,并配置更新的消息。了解有关使用 更新作业文档 更新作业参数的更多信息。

¥You can provide parameters to update specific branches or channels, and configure the update's message. Learn more about update job parameters with the update job documentation.

下一步

¥Next step

工作流是自动化开发和发布流程的强大方法。通过工作流示例指南了解如何创建开发版本、发布预览更新和创建生产版本:

¥Workflows are a powerful way to automate your development and release processes. Learn how to create development builds, publish preview updates, and create production builds with the workflows examples guide:

工作流示例

了解如何使用工作流创建开发版本、发布预览更新和创建生产版本。