首页指南参考教程

持续部署

了解如何使用指纹运行时版本在生产和开发过程中进行持续部署。


这在 SDK 51 的测试版中可用,尚未被认为是稳定的。使用可能会导致意外的系统行为。

概念

¥Concepts

指纹运行时版本控制

¥Fingerprint runtime versioning

fingerprint 运行时版本策略 在进行构建或发布更新时使用 @expo/fingerprint 包生成项目的哈希值,然后使用该哈希值作为运行时版本。哈希值是根据依赖、自定义原生代码、原生项目文件和配置等计算得出的。

¥The fingerprint runtime version policy uses the @expo/fingerprint package to generate a hash of your project when making a build or publishing an update, and then uses that hash as the runtime version. The hash is calculated based on dependencies, custom native code, native project files, and configuration, amongst other things.

通过自动计算运行时版本,你在部署构建更新时不必担心原生层与 JavaScript 应用的兼容性。

¥By automatically calculating the runtime version, you don't have to be concerned about native layer compatibility with the JavaScript application when deploying updates to builds.

持续集成 (CI) 和持续部署 (CD)

¥Continuous Integration (CI) and Continuous Deployment (CD)

React Native 项目的 CI/CD 规定每个 JS 更改(更新)都通过无线方式部署到所有兼容版本,并在运行时更改时创建新版本。

¥CI/CD for a React Native project dictates that every JS change (update) is deployed to all compatible builds over-the-air, and new builds are created when the runtime changes.

它可以通过执行大致以下步骤来完成:

¥It can be accomplished by performing roughly these steps:

  1. 运行应用测试,如果测试失败则中止。

    ¥Run application tests, abort if tests fail.

  2. 使用 npx expo-updates fingerprint:generate 命令计算相关平台的指纹。

    ¥Calculate fingerprint for relevant platforms using the npx expo-updates fingerprint:generate command.

  3. 检查运行时版本等于指纹 (eas build:list --runtimeVersion <fingerprint>) 的 EAS 版本。如果尚不存在,请创建一个新版本。

    ¥Check for EAS builds with a runtime version equal to the fingerprint (eas build:list --runtimeVersion <fingerprint>). Create a new build if none exists yet.

    • (可选)提交到应用商店以进行全面持续部署。这尚未经过测试,不推荐。

      ¥(optional) Submit to app stores for full continuous deployment. This has not yet been tested and is not recommended.

  4. 运行 eas update 以发布当前提交的更新。

    ¥Run eas update to publish an update for the current commit.

GitHub Actions

Expo 提供了一个 GitHub 行动,用于在 GitHub Actions 工作流中执行上一节中提到的步骤。

¥Expo provides a GitHub Action for performing the steps mentioned in the previous section within a GitHub Actions workflow.

调试指纹不一致

¥Debugging fingerprint inconsistencies

如果你注意到在不同的机器或环境中生成了不同的指纹,则可能意味着哈希计算中包含了意外的文件。@expo/fingerprint 有一组预定的文件用于包含/排除哈希计算,但你的项目设置通常可能需要额外的排除。对于包含原生目录(android 和 ios)的项目,这更常见。

¥If you notice different fingerprints being generated across different machines or environments, it may mean that unanticipated files are being included in the hash calculation. @expo/fingerprint has a predetermined set of files to include/exclude for hash calculation, but often your project setup may require additional excludes. For projects that include native directories (android and ios) this is more common.

我们提供用于识别哪些文件导致指纹不一致的工具,以及将这些文件从项目指纹计算中排除的机制。

¥We provide tools for identifying which files are causing fingerprint inconsistencies and mechanisms to exclude those files from fingerprint calculations for your project.

要识别不同机器或环境中的指纹差异:

¥To identify differences in fingerprints on different machines or environments:

  • 在每台机器/环境(npx expo-updates fingerprint:generate)上运行指纹生成命令时,传递 --debug 标志。

    ¥When running fingerprint generation commands on each machine/environment (npx expo-updates fingerprint:generate), pass --debug flag.

  • 这些命令运行的差异输出以确定导致差异的文件。这些工具可能会有所帮助:

    ¥Diff outputs from those command runs to determine files causing the difference. These tools may be helpful:

    • JSON Pretty Print 格式化输出。

      ¥JSON Pretty Print to format the output.

    • JSON Diff 比较输出并识别导致差异的文件。

      ¥JSON Diff to compare the output and identify the files causing the discrepancies.

要排除导致差异的文件,请将它们添加到 .fingerprintignore 文件中,如 @expo/fingerprint 自述文件 中所述。

¥To exclude files causing the differences, add them to the .fingerprintignore file as described in the @expo/fingerprint README.

使用 GitHub Actions 进行调试

¥Debugging with GitHub Actions

在调试模式下运行工作流将自动将 --debug 标志添加到作为操作的一部分运行的命令中,并且输出将在工作流运行日志中可用。

¥Running the workflow in debug mode will automatically add the --debug flag to the commands run as part of the action, and the output will be available in the workflow run logs.

Expo 中文网 - 粤ICP备13048890号