自动执行 EAS CLI 命令
了解如何使用 EAS 工作流自动执行一系列 EAS CLI 命令。
如果你使用 EAS CLI 构建、提交和更新应用,则可以自动执行以下序列使用 EAS 工作流的命令。EAS 工作流可以构建、提交和更新你的应用,同时还可以运行其他作业,如 Maestro 测试、单元测试、自定义脚本等。
¥If you're using EAS CLI to build, submit, and update your app, you can automate sequences of commands with EAS Workflows. 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 you can run them using 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.
创建构建
¥Creating builds
你可以使用 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 could run the following EAS CLI command:
-
eas build --platform ios --profile production
要将此命令编写为工作流,请在项目根目录下创建一个名为 .eas/workflows/build-ios-production.yml 的工作流文件。
¥To write this command as 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.
name: iOS production build
on:
push:
branches: ['main']
jobs:
build_ios:
name: Build iOS
type: build
params:
platform: ios
profile: production
获得此工作流文件后,你可以通过向 main
分支推送提交或运行以下 EAS CLI 命令来启动它:
¥Once you have this workflow file, you can kick it off by pushing a commit to the main
branch, or by running the following EAS CLI command:
-
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.
提交构建
¥Submitting builds
你可以使用 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 could run the following EAS CLI command:
-
eas submit --platform ios
要将此命令编写为工作流,请在项目根目录下创建一个名为 .eas/workflows/submit-ios.yml 的工作流文件。
¥To write this command as 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.
name: Submit iOS app
on:
push:
branches: ['main']
jobs:
submit_ios:
name: Submit iOS
type: submit
params:
platform: ios
获得此工作流文件后,你可以通过向 main
分支推送提交或运行以下 EAS CLI 命令来启动它:
¥Once you have this workflow file, you can kick it off by pushing a commit to the main
branch, or by running the following EAS CLI command:
-
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.
发布更新
¥Publishing updates
你可以使用 EAS CLI 和 eas update
命令更新你的应用。要更新应用,你可以运行以下 EAS CLI 命令:
¥You can update your app using EAS CLI with the eas update
command. To update your app, you could run the following EAS CLI command:
-
eas update --auto
要将此命令编写为工作流,请在项目根目录下创建一个名为 .eas/workflows/publish-update.yml 的工作流文件。
¥To write this command as 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.
name: Publish update
on:
push:
branches: ['*']
jobs:
update:
name: Update
type: update
params:
branch: ${{ github.ref_name || 'test'}}
获得此工作流文件后,你可以通过向任何分支推送提交或运行以下 EAS CLI 命令来启动它:
¥Once you have this workflow file, you can kick it off by pushing a commit to any branch, or by running the following EAS CLI command:
-
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:
了解如何使用工作流创建开发版本、发布预览更新和创建生产版本。