示例 CI/CD 工作流程
对你的项目有用的常见 CI/CD 工作流。
以下工作流程是如何使用 EAS 工作流程自动化开发和发布流程的示例。它们可以帮助你和你的团队进行开发、审查彼此的 PR 并向你的用户发布更改。
¥The following workflows are examples of how you can use EAS Workflows to automate your development and release processes. They can help you and your team develop, review each other's PRs, and release changes to your users.
开发构建工作流程
¥Development builds workflow
开发构建 是你项目的专门版本,其中包括 Expo 的开发者工具。这些类型的构建包括项目内的所有原生依赖,使你可以在模拟器、模拟器或物理设备上运行类似于生产的项目构建。
¥Development builds are specialized builds of your project that include Expo's developer tools. These types of builds include all native dependencies inside your project, enabling you to run a production-like build of your project on a simulator, emulator, or a physical device.
2 requirements
2 requirements
1.
Set up your environment
首先,你需要配置你的项目和设备以构建和运行开发版本。通过以下指南了解如何为开发版本设置环境:
¥To get started, you'll need to configure your project and devices to build and run development builds. Learn how to set up your environment for development builds with the following guides:
让你的项目准备好进行开发构建。
让你的项目准备好进行开发构建。
让你的项目准备好进行开发构建。
让你的项目准备好进行开发构建。
2.
Create build profiles
配置项目和设备后,将以下构建配置文件添加到 eas.json 文件中。
¥After you've configured your project and devices, add the following build profiles to your eas.json file.
{
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"development-simulator": {
"developmentClient": true,
"distribution": "internal",
"ios": {
"simulator": true
}
}
}
}
以下工作流程为每个平台以及物理设备、Android 模拟器和 iOS 模拟器创建一个构建。它们都将并行运行。
¥The following workflow creates a build for each platform and for both physical devices, Android emulators, and iOS simulators. They all will run in parallel.
name: Create development builds
jobs:
android_development_build:
name: Build Android
type: build
params:
platform: android
profile: development
ios_device_development_build:
name: Build iOS device
type: build
params:
platform: ios
profile: development
ios_simulator_development_build:
name: Build iOS simulator
type: build
params:
platform: ios
profile: development-simulator
使用以下命令运行上述工作流程:
¥Run the above workflow with:
-
eas workflow:run .eas/workflows/create-development-builds.yml
预览更新工作流程
¥Preview updates workflow
对项目进行更改后,你可以通过发布 预览更新 与你的团队分享更改预览。
¥Once you've made changes to your project, you can share a preview of your changes with your team by publishing a preview update.
你可以在开发构建 UI 中访问预览更新,也可以通过 Expo 仪表板上的可扫描二维码访问。在每次提交时发布预览时,你的团队可以查看更改,而无需提取最新更改并在本地运行它们。
¥You can access preview updates in the development build UI and through scannable QR codes on the Expo dashboard. When publishing a preview on every commit, your team can review changes without pulling the latest changes and running them locally.
2 requirements
2 requirements
1.
Set up EAS Update
你的项目需要设置 EAS 更新 才能发布预览更新。你可以使用以下方式设置你的项目:
¥Your project needs to have EAS Update setup to publish preview updates. You can set up your project with:
-
eas update:configure
2.
Create new development builds
配置项目后,为每个平台创建新的 开发构建。
¥After you've configured your project, create new development builds for each platform.
以下工作流程会为每个分支上的每次提交发布预览更新。
¥The following workflow publishes a preview update for every commit on every branch.
name: Publish preview update
on:
push:
branches: ['*']
jobs:
publish_preview_update:
name: Publish preview update
type: update
params:
branch: ${{ github.ref_name || 'test' }}
部署到生产工作流程
¥Deploy to production workflow
当你准备好向用户提供更改时,你可以构建并提交到应用商店,也可以发送无线更新。以下工作流程检测你是否需要新构建,如果需要,它会将它们发送到应用商店。如果不需要新版本,它将发送无线更新。
¥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.
3 requirements
3 requirements
1.
Set up EAS Build
要设置 EAS Build,请遵循以下指南:
¥To set up EAS Build, follow this guide:
Get your project ready for EAS Build.
2.
Set up EAS Submit
要设置 EAS Submit,请遵循 Google Play Store 和 Apple App Store 提交指南:
¥To set up EAS Submit, follow the Google Play Store and Apple App Store submissions guides:
Get your project ready for Google Play Store submissions.
Get your project ready for Apple App Store submissions.
3.
Set up EAS Update
最后,你需要设置 EAS 更新,你可以使用以下方法执行此操作:
¥And finally, you'll need to set up EAS Update, which you can do with:
-
eas update:configure
以下工作流程在每次推送到 main
分支时运行并执行以下操作:
¥The following workflow runs on each push to the main
branch and performs the following:
-
使用 Expo 指纹 对项目的原生特性进行哈希处理。
¥Takes a hash of the native characteristics of the project using Expo Fingerprint.
-
检查指纹是否已存在构建。
¥Checks if a build already exists for the fingerprint.
-
如果构建不存在,它将构建项目并将其提交到应用商店。
¥If a build does not exist, it will build the project and submit it to the app stores.
-
如果构建存在,它将发送无线更新。
¥If a build exists, it will send an over-the-air update.
name: Deploy to production
on:
push:
branches: ['main']
jobs:
fingerprint:
name: Fingerprint
type: fingerprint
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