使用 EAS Workflows 部署到生产环境

了解如何使用 EAS Workflows 部署到生产环境。


当你准备向用户发布更新时,你可以构建并提交到应用商店,或者发送无线更新。以下工作流程会检测是否需要新的构建,如果需要,它会将其发送到应用商店。如果不需要新的构建,它将发送无线更新。

🌐 When you're ready to deliver changes to your users, you can build and submit to the app stores or you can send an over-the-air update. The following workflow detects if you need new builds, and if so, it sends them to the app stores. If new builds are not required, it will send an over-the-air update.

Expo 黄金工作流程:使用自动化工作流程将你的应用部署到生产环境
Expo 黄金工作流程:使用自动化工作流程将你的应用部署到生产环境

开始使用

🌐 Get started

Prerequisites

3 requirements

1.

设置 EAS 构建

要设置 EAS Build,请按照本指南操作:

EAS 构建前提条件

让你的项目为 EAS 构建做好准备。

3.

设置 EAS 更新

最后,你需要设置 EAS Update,可以通过以下方式进行:

Terminal
eas update:configure

以下工作流程会在每次推送到 main 分支时运行,并执行以下操作:

🌐 The following workflow runs on each push to the main branch and performs the following:

  • 使用 Expo Fingerprint 对项目的本地特性进行哈希处理。
  • 检查指纹是否已存在构建。
  • 如果构建不存在,它将构建项目并将其提交到应用商店。
  • 如果构建存在,它将发送无线更新。
.eas/workflows/deploy-to-production.yml
name: Deploy to production on: push: branches: ['main'] jobs: fingerprint: name: Fingerprint type: fingerprint environment: production get_android_build: name: Check for existing android build needs: [fingerprint] type: get-build params: fingerprint_hash: ${{ needs.fingerprint.outputs.android_fingerprint_hash }} profile: production get_ios_build: name: Check for existing ios build needs: [fingerprint] type: get-build params: fingerprint_hash: ${{ needs.fingerprint.outputs.ios_fingerprint_hash }} profile: production build_android: name: Build Android needs: [get_android_build] if: ${{ !needs.get_android_build.outputs.build_id }} type: build params: platform: android profile: production build_ios: name: Build iOS needs: [get_ios_build] if: ${{ !needs.get_ios_build.outputs.build_id }} type: build params: platform: ios profile: production submit_android_build: name: Submit Android Build needs: [build_android] type: submit params: build_id: ${{ needs.build_android.outputs.build_id }} submit_ios_build: name: Submit iOS Build needs: [build_ios] type: submit params: build_id: ${{ needs.build_ios.outputs.build_id }} publish_android_update: name: Publish Android update needs: [get_android_build] if: ${{ needs.get_android_build.outputs.build_id }} type: update params: branch: production platform: android publish_ios_update: name: Publish iOS update needs: [get_ios_build] if: ${{ needs.get_ios_build.outputs.build_id }} type: update params: branch: production platform: ios