Skip to main content

构建并部署你的应用

现在你已经构建了第一个应用,你将希望将其分发出去,以便每个人都可以开始使用它。构建和部署应用的过程可能相当繁琐。这就是 Appflow 发挥作用的地方。Appflow 允许你有效地生成 Web 和原生构建,推送实时应用更新,将应用发布到应用商店,并自动化整个过程。完整的快速入门指南可以在 这里 找到。

🌐 Now that you have built your first app, you are going to want to get it distributed so everyone can start using it. The mechanics of building and deploying your application can be quite cumbersome. That is where Appflow comes into play. Appflow allows you to effectively generate web and native builds, push out live app updates, publish your app to the app stores, and automate the whole process. The entire Quickstart guide can be found here.

下面我们将概述这些步骤。

🌐 Below we will run through an overview of the steps.

连接你的存储库

🌐 Connect Your Repo

Appflow 直接与 Git 版本控制协作,并使用你现有的代码库作为部署和打包构建的真实来源。你首先需要与你的托管服务集成,例如 GitHub 或 Bitbucket,或者你可以将代码直接推送到 Appflow。一旦完成,Appflow 就可以访问你的代码。

🌐 Appflow works directly with Git version control and uses your existing code base as the source of truth for Deploy and Package builds. You will first need to integrate with your hosting service, such as GitHub or Bitbucket, or you can push your code directly to Appflow. Once this is completed, Appflow will have access to your code.

有关将你的代码仓库连接到 Appflow 的更多信息,请查看 Appflow 文档中的 连接你的仓库 部分。

🌐 For more on connecting your code repository to Appflow, checkout the Connect your Repo section inside the Appflow docs.

安装 Appflow SDK

🌐 Install the Appflow SDK

Appflow SDK(也称为 Ionic Deploy 插件)将允许你利用可以说是 Appflow 两个最佳功能:向你的应用部署实时更新以及绕过应用商店。Ionic Appflow 的实时更新功能随 Appflow SDK 一起提供,并具有检测和同步你在仪表板中已推送到已识别通道的应用更新的能力。

🌐 The Appflow SDK (also known as Ionic Deploy plugin) will allow you to take advantage of arguably two of the best Appflow features: deploying live updates to your app and bypassing the app stores. Ionic Appflow's Live Update feature is shipped with Appflow SDK and features the capabilities of detecting and syncing the updates for your app that you have pushed to your identified channels within the dashboard.

要将 Appflow SDK 插件添加到你的项目中,你可以在 Appflow 仪表板中点击 Deploy > Destinations 部分内的“安装说明”来遵循安装说明。或者,你也可以在应用的根目录中执行以下命令手动安装该插件:

🌐 To get the Appflow SDK plugin added to your project, you can follow the install instructions within the Appflow Dashboard by clicking on "Install Instructions" inside of the Deploy > Destinations section. Alternatively, you can install the plugin manually by executing the following command in your app's root directory:

ionic deploy add  \
--app-id="YOUR_APP_ID" \
--channel-name="YOUR_CHANNEL_NAME" \
--update-method="background|auto|none" \

有关安装 Appflow SDK 的先决条件和附加说明,请访问 Appflow 文档中的 安装 Appflow SDK 部分。

🌐 For prerequisite and additional instructions on installing the Appflow SDK, visit the Install the Appflow SDK section inside the Appflow docs.

推送提交

🌐 Push a Commit

为了让 Appflow 访问你代码的最新和最重要的更改,你需要通过你选择的版本控制集成推送一次提交。对于使用 GitHub 或 Bitbucket 的用户,操作如下:

🌐 In order for Appflow to access the latest and greatest changes to your code, you will need to push a commit via the version control integration of your choosing. For those that use GitHub or Bitbucket, this would look as follows:

git add . # stage any changes
git commit -m "added appflow sdk" # commit staged changes
git push origin main # push the changes from the main branch to your git host

推送完成后,你将会在 Appflow 仪表板的 Commits 标签下看到你的提交。更多信息,请查看 Appflow 文档中的 推送提交 部分。

🌐 After the push is made, you will then see your commit under the Commits tab of the Appflow Dashboard. For more on this, take a look at the Push a Commit section inside the Appflow docs.

部署实时更新

🌐 Deploy a Live Update

安装了 Appflow SDK 并将提交推送到仪表板后,你就可以准备将实时更新部署到设备了。实时更新功能使用已安装的 Appflow SDK 与你的原生应用一起,监听特定的部署通道目标。当实时更新被分配到某个通道目标时,该更新将部署到运行已配置为监听该特定通道目标二进制文件的用户设备上。

🌐 With the Appflow SDK installed and your commit pushed up to the Dashboard, you are ready to deploy a live update to a device. The Live Update feature uses the installed Appflow SDK with your native application to listen to a particular Deploy Channel Destination. When a live update is assigned to a Channel Destination, that update will be deployed to user devices running binaries that are configured to listen to that specific Channel Destination.

要部署实时更新,需要创建一个 Web 构建。这可以通过 Commits 选项卡中的 Start build 图标或点击 Build > Builds 选项卡右上角的 New build 按钮来完成。选择要部署的正确提交后,选择 Web 目标平台和 Latest 构建堆栈。根据你的 Appflow 计划,如果配置了自定义环境,你将能够包含它们。最后,你可以启用 Live Update 并选择通道,以在构建成功完成后自动分配该构建。

🌐 To get the live update deployed, a Web build will need to be created. This can be done through the Start build icon from the Commits tab or by clicking the New build button in the top right corner of the Build > Builds tab. After selecting the correct commit to deploy, select the Web target platform and the Latest build stack. Depending on your Appflow plan, you will then be able to include custom environments, if any are configured. Finally, you can enable Live Update and pick the Channel to automatically assign the build to once it successfully completes.

在完成 Web 构建后,你可以使用额外的版本控制选项。在完成此部分并且成功完成部署构建后,你可以通过点击构建详情页面中的 Deploy live updates 按钮,将其分配到你在安装 Appflow SDK 时配置的相同通道。同样,你也可以在 Build > Builds 选项卡中点击构建上的 Deploy live updates 图标,并从下拉菜单中选择通道。

🌐 Upon completion of the Web Build, additional versioning options are available to you. After completing this section and you have a successful Deploy build, you can then assign it to the same Channel you configured the Appflow SDK to listen to when you installed it by clicking the Deploy live updates button in the build detail page. The same can be done by clicking the Deploy live updates icon on the build in the Build > Builds tab and select the Channel from the dropdown.

要接收此实时更新,你需要在设备或模拟器上运行该应用。实现此操作最快且最简单的方法是通过以下命令:

🌐 To receive this live update, you will need to run the app on a device or an emulator. The quickest and easiest way to do this is through the following command:

ionic cordova run [ios | android] [options]

假设应用已正确配置为监听你部署的通道,如果在设置过程中选择了自动更新方法,应用在启动时应立即更新。如果选择了后台更新方法,请确保在应用中停留约30秒以确保更新已下载。然后,关闭应用,重新打开,你将看到更新已应用!

🌐 Assuming the app is configured correctly to listen to the channel you deployed to, the app should immediately update on startup if you have chosen the auto update method during setup. If the background update method was chosen, be sure to stay in the app for about 30 seconds to ensure the update was downloaded. Then, close the application, reopen it, and you will see the updates applied!

要深入了解部署实时更新的步骤,以及诸如在开发中禁用部署等附加信息,请查看 Appflow 文档中的 部署实时更新 部分。

🌐 To dive into more details on the steps to deploy a live update, as well as additional information such as disabling deploy for development, check out the Deploy a Live Update section inside the Appflow docs.

构建原生二进制文件

🌐 Build a Native Binary

接下来是为你的应用构建和部署流程创建本地二进制文件。这是通过 Ionic Package 服务完成的。首先,你需要创建一个 Package build。可以通过点击 Commits 选项卡中的 Start build 图标,或在 Build > Builds 选项卡的右上角点击 New build 按钮来完成。然后,你将选择适合的提交进行构建,并填写所有必填字段以及你希望指定的任何可选字段。在填写完所有信息并开始构建后,你可以查看构建进度,并在遇到任何错误时查看日志。

🌐 Next up is a native binary for your app build and deploy process. This is done via the Ionic Package service. First things first, you will need to create a Package build. This can be done by clicking the Start build icon from the Commits tab or by clicking the New build button in the top right from the Build > Builds tab. Then you will select the proper commit for your build and fill in all of the several required fields and any optional fields that you want to specify. After filling in all of the information and the build begins, you can check out it's progress and review the logs if you encounter any errors.

在成功完成软件包构建后,iOS 二进制文件(.ipa 或 IPA)和/或 Android 二进制文件(.apk 或 APK)将可供使用。随后可以下载该文件,以便通过在构建详情页面右侧的 Artifacts 区域中点击文件名,或在 Build > Builds 选项卡中的构建上点击 Download IPA/APK 图标,将其安装到设备上。

🌐 Given a successful Package build, an iOS binary (.ipa or IPA) or/and an Android binary (.apk or APK) file becomes available to you. The file can subsequently be downloaded so you can install it on a device by clicking the file name in the Artifacts section in the right of the build detail page or clicking the Download IPA/APK icon on the build in the Build > Builds tab.

有关构建本地二进制文件的更多信息,可以在 Appflow 文档中的 构建本地二进制文件 部分找到。

🌐 Further information regarding building native binaries can be found inside of the Build a Native Binary section inside the Appflow docs.

创建自动化

🌐 Create an Automation

自动化 使你和你的团队能够充分利用 Appflow 的 CI/CD 功能。你可以创建自动化,每当你的团队向指定分支提交新代码时,就触发 打包构建部署构建。这些自动化还可以配置为使用不同的环境和原生配置,以构建用于开发、预发、质量保证和生产的不同版本的应用。

欲了解更多信息,请访问 Appflow 文档中的 创建自动化 部分。在那里,你将看到有关创建单个自动化的详细信息。不过,你可以为不同的分支或工作流创建多个自动化,并根据你的需求进行自定义。需要注意的是,创建自动化的功能适用于我们的 基础计划 及以上用户。

🌐 For more information, visit the Create an Automation section within the Appflow docs. There you will see details on creating a single automation. However, you can create multiple automations for different branches or workflows and customize them to fit your needs. An important note is that the ability to create an automation is available for those on our Basic plans and above.

创造环境

🌐 Create an Environment

打包构建部署构建可以通过环境进一步自定义。这个强大的功能允许你根据构建时传入的环境变量创建不同的配置。当与自动化功能结合使用时,开发团队可以轻松配置开发、预发布和生产构建配置,使他们能够采用 DevOps 最佳实践,并比以往更快地交付更高质量的更新。

创建环境功能可供使用我们基础计划及以上的用户使用。有关更多信息,请参阅 Appflow 文档中的创建环境部分。

🌐 Creating an Environment is available for those on our Basic plans and above. More information on this can be found in the Create an Environment section within the Appflow docs.

创建原生配置

🌐 Create a Native Configuration

本地配置 允许你轻松修改在不同环境(开发、生产、预发布等)之间可能变化的常见配置值,因此你无需使用额外的逻辑或手动将它们提交到版本控制中。本地配置可以附加到任何 软件包构建自动化 上。

原生配置可用于:

🌐 Native configs can be used to:

要访问创建本地配置的功能,你需要订阅我们的基础计划及以上版本。有关此功能的更多详细信息,请参阅 Appflow 文档中的创建本地配置部分。

🌐 For access to the ability to create a Native Configuration, you will need to be on our Basic plans and above. Additional details of this feature can be found in the Create a Native Configuration section within the Appflow docs.

下一步是什么?

🌐 What’s Next?

恭喜!你开发了一个完整的跨平台照片图库应用,可以在网页、iOS 和 Android 上运行。不仅如此,你还构建了该应用并将其部署到用户的设备上!

🌐 Congratulations! You developed a complete cross-platform Photo Gallery app that runs on the web, iOS, and Android. Not only that, you have also then built the app and deployed it to your users' devices!

从这里有许多路径可以选择。尝试在应用中添加另一个Ionic UI 组件,或更多原生功能。天高任鸟飞。一旦你添加了另一个功能,通过 Appflow 再次运行构建和部署流程,将其发布给你的用户。

🌐 There are many paths to follow from here. Try adding another Ionic UI component to the app, or more native functionality. The sky’s the limit. Once you have added another feature, run the build and deploy process again through Appflow to get it out to your users.

祝你愉快地构建应用!💙

🌐 Happy app building! 💙