This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

开始使用 EAS 工作流

了解如何使用 EAS Workflows 自动化你的 React Native CI/CD 开发和发布流程。


本页面将引导你创建第一个 EAS 工作流:为 Android 模拟器、iOS 模拟器、实际设备制作开发版本,以及为应用商店制作生产版本。

🌐 This page walks you through creating your first EAS Workflow: development builds of your app for Android emulators, iOS simulators, physical devices, and production builds for the app stores.

开始使用

🌐 Get started

先决条件

3 要求

1.

注册一个 Expo 账户

你需要注册一个 Expo 账户。

2.

创建项目

你需要使用以下命令创建一个项目:

Terminal
- npx create-expo-app@latest
- yarn create expo-app
- pnpm create expo-app
- bun create expo

3.

安装 EAS CLI

你需要安装 EAS CLI 来创建和运行工作流程:

Terminal
- npm install -g eas-cli

1

运行以下命令来创建一个为 Android 和 iOS 制作开发版本的工作流程:

🌐 Run the following command to create a workflow that creates development builds for Android and iOS:

Terminal
- eas workflow:create --template build

然后在出现提示时按照提示和 [Action requested] 步骤操作。该命令会在 .eas/workflows/build.yml 生成一个工作流文件,并为你的项目在 EAS 上构建做好设置。

🌐 Then follow the prompts and the [Action requested] steps when they appear. The command generates a workflow file at .eas/workflows/build.yml and sets up your project for building on EAS.

2

使用以下命令运行工作流:

🌐 Run the workflow with the following command:

Terminal
- eas workflow:run .eas/workflows/build.yml

一旦你这么做,你就可以在你项目的工作流页面上观看工作流的运行情况。

🌐 Once you do, you can watch your workflow run on your project's workflows page.

3

当构建完成后,你可以通过网站界面把它们安装到你的实体设备上。你也可以运行以下命令,将最新的构建安装到你的 Android 模拟器和 iOS 模拟器上:

🌐 When the builds finish, you can install them on your physical devices via the website UI. You can also run the following commands to install the latest builds on your Android Emulator and iOS Simulator:

Terminal
- eas build:run -p android --latest
Terminal
- eas build:run -p ios -e development-ios-simulator --latest

然后,启动一个开发服务器,这样开发版就能加载你的应用了:

🌐 Then, start a development server so the development build can load your app:

Terminal
- npx expo start

创建生产版本

🌐 Create production builds

当你准备好为应用商店构建时,使用 deploy 模板生成一个发布工作流程:

🌐 When you're ready to build for the app stores, generate a release workflow with the deploy template:

Terminal
- eas workflow:create --template deploy

这会为你的项目设置自动部署:它会配置 EAS Build 和 EAS Update,并设置你的应用标识符,然后将完整的发布工作流程写入 .eas/workflows/deploy.yml。

🌐 This sets up your project for automated deployment: it configures EAS Build and EAS Update and sets your app identifiers, then writes a complete release workflow to .eas/workflows/deploy.yml.

当你运行它时,这个工作流程会为你的项目生成指纹,然后在有原生更改时构建并提交新的生产版本,以便准备提交;如果已经存在匹配的版本,它会发布一个空中更新,立刻发送给你的用户。

🌐 When you run it, the workflow fingerprints your project, then builds and submits a new production build when there are native changes so they're ready for submission, or publishes an over-the-air update when a matching build already exists, which will be sent to your users immediately.

想了解生成的工作流程的操作步骤,请参阅 部署到生产示例。

🌐 For a walkthrough of the generated workflow, see the Deploy to production example.

如果你只需要创建生产版本,可以为每个平台使用一个 build 任务的工作流:

🌐 If you only need to create production builds, use a workflow with a build job for each platform:

.eas/workflows/create-production-builds.yml
name: Create Production Builds jobs: build_android: type: build # This job type creates a production build for Android params: platform: android profile: production build_ios: type: build # This job type creates a production build for iOS params: platform: ios profile: production

这个工作流使用你 eas.json 中的 production 配置。生产版本构建需要应用签名凭证。使用以下命令为每个平台设置它们:

🌐 This workflow uses the production profile from your eas.json. Production builds require app signing credentials. Set them up for each platform with the following commands:

Terminal
- eas credentials:configure-build -p android -e production
Terminal
- eas credentials:configure-build -p ios -e production

然后,运行工作流程:

🌐 Then, run the workflow:

Terminal
- eas workflow:run .eas/workflows/create-production-builds.yml

更多

🌐 More

使用 GitHub 事件自动化工作流程

🌐 Automate workflows with GitHub events

你可以通过将提交推送到你的 GitHub 仓库来触发工作流。你可以按照以下步骤将 GitHub 仓库链接到你的 EAS 项目:

🌐 You can trigger a workflow by pushing a commit to your GitHub repository. You can link a GitHub repo to your EAS project with the following steps:

  • 导航到你项目的 GitHub 设置。
  • 按照 UI 安装 GitHub 应用。
  • 选择与 Expo 项目匹配的 GitHub 存储库并连接它。

然后,将 on 触发器 添加到你的工作流文件中。例如,如果你想在提交推送到 main 分支时触发工作流,可以添加以下内容:

🌐 Then, add the on trigger to your workflow file. For example, if you want to trigger the workflow when a commit is pushed to the main branch, you can add the following:

.eas/workflows/create-production-builds.yml
name: Create Production Builds on: push: branches: ['main'] jobs: build_android: type: build params: platform: android profile: production build_ios: type: build params: platform: ios profile: production

从 App Store Connect 事件触发工作流

🌐 Trigger workflows from App Store Connect events

你也可以使用 on.app_store_connect 从 App Store Connect 事件触发工作流。

🌐 You can also trigger workflows from App Store Connect events using on.app_store_connect.

在使用 App Store Connect 触发器之前,请在 EAS 仪表板中配置你的 App Store Connect 连接:

🌐 Before using App Store Connect triggers, configure your App Store Connect connection in EAS dashboard:

示例工作流程:

🌐 Example workflow:

.eas/workflows/app-store-connect-events.yml
name: React to App Store Connect events on: app_store_connect: app_version: states: - ready_for_review - waiting_for_review jobs: send_slack_notification: type: slack environment: production params: webhook_url: ${{ env.SLACK_WEBHOOK_URL }} message: 'App version is ready for review or waiting for review.'

示例会从 SLACK_WEBHOOK_URL 环境变量 中读取 webhook URL。在运行工作流之前,请在 production 环境中创建它。

🌐 The example reads the webhook URL from a SLACK_WEBHOOK_URL environment variable. Create it in the production environment before running the workflow.

VS Code 扩展

🌐 VS Code extension

下载 Expo 工具 VS Code 扩展,以获取工作流文件的描述和自动补齐。

🌐 Download the Expo Tools VS Code extension to get descriptions and autocompletions for your workflow files.