使用 EAS CLI 管理分支和渠道

了解如何将分支链接到通道并使用 EAS CLI 发布更新。


EAS 更新通过将 分支通道 关联来工作。通道在构建时指定,并存在于构建的原生代码中。分支是一系列有序的更新,类似于 Git 分支,它是一个有序的提交列表。使用 EAS 更新,我们可以将任何通道链接到任何分支,从而允许我们向不同的构建提供不同的更新。

🌐 EAS Update works by linking branches to channels. Channels are specified at build time and exist inside a build's native code. Branches are an ordered list of updates, similar to a Git branch, which is an ordered list of commits. With EAS Update, we can link any channel to any branch, allowing us to make different updates available to different builds.

上图展示了这一关联。在这里,我们有与名为“version-1.0”的分支关联的“生产”通道的构建。当我们准备好时,可以调整通道与分支的指针。假设我们在名为“version-2.0”的分支上测试并准备了更多修复,可以更新此关联,使所有具有“生产”通道的构建都可使用“version-2.0”分支。

🌐 The diagram above visualizes this link. Here, we have the builds with the "production" channel linked to the branch named "version-1.0". When we're ready, we can adjust the channel–branch pointer. Imagine we have more fixes tested and ready on a branch named "version-2.0". We could update this link to make the "version-2.0" branch available to all builds with the "production" channel.

检查项目更新的状态

🌐 Inspecting the state of your project's updates

检查渠道

🌐 Inspect channels

查看所有通道:

🌐 View all channels:

Terminal
eas channel:list

查看特定通道:

🌐 View a specific channel:

Terminal
eas channel:view [channel-name]

# Example
eas channel:view production

创建通道:

🌐 Create a channel:

Terminal
eas channel:create [channel-name]

# Example
eas channel:create production

视察分行

🌐 Inspect branches

查看所有分支:

🌐 See all branches:

Terminal
eas branch:list

查看特定分支及其更新列表:

🌐 See a specific branch and a list of its updates:

Terminal
eas branch:view [branch-name]


# Example
eas branch:view version-1.0

检查更新

🌐 Inspect updates

查看具体更新:

🌐 View a specific update:

Terminal
eas update:view [update-group-id]

# Example
eas update:view dbfd479f-d981-44ce-8774-f2fbcc386aa

更改项目更新的状态

🌐 Changing the state of your project's updates

创建新更新并发布

🌐 Create a new update and publish it

Terminal
eas update --branch [branch-name] --message "..."

# Example
eas update --branch version-1.0 --message "Fixes typo"

如果你正在使用 Git,我们可以使用 --auto 标志来自动填写分支名称和信息。该标志将使用当前的 Git 分支作为分支名称,并使用最新的 Git 提交信息作为消息。

🌐 If you're using Git, we can use the --auto flag to auto-fill the branch name and the message. This flag will use the current Git branch as the branch name and the latest Git commit message as the message.

Terminal
eas update --auto

删除分支

🌐 Delete a branch

Terminal
eas branch:delete [branch-name]

# Example
eas branch:delete version-1.0

重命名分支

🌐 Rename a branch

重命名分支不会断开任何通道-分支的链接。如果你有一个名为“production”的通道链接到一个名为“version-1.0”的分支,然后你将名为“version-1.0”的分支重命名为“version-1.0-new”,那么“production”通道将会链接到现在已重命名的分支“version-1.0-new”上。

🌐 Renaming branches do not disconnect any channel–branch links. If you had a channel named "production" linked to a branch named "version-1.0", and then you renamed the branch named "version-1.0" to "version-1.0-new", the "production" channel would be linked to the now-renamed branch "version-1.0-new".

Terminal
eas branch:rename --from [branch-name] --to [branch-name]

# Example
eas branch:rename --from version-1.0 --to version-1.0-new

在分支内重新发布以前的更新

🌐 Republish a previous update within a branch

我们可以让之前的更新立即对所有用户可用。此命令会将之前的更新再次发布,从而使其成为分支上最新的更新。当用户重新打开应用时,应用将看到新重新发布的更新并进行下载。

🌐 We can make a previous update immediately available to all users. This command takes the previous update and publishes it again so that it becomes the most current update on the branch. As your users re-open their apps, the apps will see the newly re-published update and will download it.

重新发布类似于 Git 回退操作,即将正确的提交放置在 Git 历史的顶部。

Terminal
eas update:republish --group [update-group-id]
eas update:republish --branch [branch-name]

# Example
eas update:republish --group dbfd479f-d981-44ce-8774-f2fbcc386aa
eas update:republish --branch version-1.0

如果你不知道确切的更新组 ID,你可以使用 --branch 标志。这会显示该分支上最近更新的列表,并允许你选择要重新发布的更新组。