本教程专注于 GitHub 主机,但您可以通过一些微调来适应任何其他 CI/CD 平台。
前言
Be sure you have added your Capacitor app first to Capgo, this tutorial just focuses on the upload phase
提交约定
首先,您需要遵循提交约定 上下文:Capgo Builder / 原生云构建产品页面。角色:短 UI 标签或导航项。消息键 `native_build_builder_credit_first` (原生构建构建者首先)。规范提交

GitHub actions for tag
GitHub 动作(标签)
然后您需要创建第一个 __CAPGO_KEEP_0__ 动作来自动构建并创建标签。 .github/workflows/bump_version.yml
在此路径创建一个文件:
name: Bump version
on:
push:
branches:
- main
- development
jobs:
bump-version:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
runs-on: ubuntu-latest
name: "Bump version and create changelog with standard version"
steps:
- name: Check out
uses: actions/checkout@v6
with:
fetch-depth: 0
filter: blob:none
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
- name: Git config
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
- name: Create bump and changelog
if: github.ref == 'refs/heads/main'
run: npx capacitor-standard-version
- name: Create bump and changelog
if: github.ref != 'refs/heads/main'
run: npx capacitor-standard-version --prerelease alpha
- name: Push to origin
run: |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git pull $remote_repo $CURRENT_BRANCH
git push $remote_repo HEAD:$CURRENT_BRANCH --follow-tags --tags
将为您的主 branch 中的每个提交发布一个标签。并且一个 alpha 发布为 development, 最后一个提交的每个提交的更改日志条目 CHANGELOG.md.
不要担心,如果您没有这个文件,它将为您创建。
要使其工作,您需要创建一个 个人访问令牌 并将其添加到您的GitHub 秘密 作为 PERSONAL_ACCESS_TOKEN.
这是必要的,以便 CI 可以提交更改日志和版本更新。
当您创建令牌时,请选择过期时间为 never 并且范围为 repo.
设置 version 在你的 package.json 文件中。使用最新版本的
仅在第一次使用时需要,之后工具将自动更新。
You can now commit this both files and see your first tag appear in GitHub!
capacitor-standard-version 是负责魔法的包, 默认情况下,它还会在安卓和IOS中更新你的版本号
GitHub actions for build
创建一个文件到这个路径: .github/workflows/build.yml
内容如下:
name: Build source code and send to Capgo
on:
push:
tags:
- '*'
jobs:
deploy:
runs-on: ubuntu-latest
name: "Build code and release"
steps:
- name: Check out
uses: actions/checkout@v6
- name: Install dependencies
id: install_code
run: npm i
- name: Build
id: build_code
run: npm build
env:
MY_ENV_VAR: ${{ secrets.MY_ENV_VAR }}
- name: Create Release Alpha
if: "contains(github.ref, '-alpha.')"
id: create_release_prepro
run: npx @capgo/cli@latest bundle upload -a ${{ secrets.CAPGO_TOKEN }} -c development
- name: Create Release Production
if: "!contains(github.ref, '-alpha.')"
id: create_release_prod
run: npx @capgo/cli@latest bundle upload -a ${{ secrets.CAPGO_TOKEN }} -c production
This will install and build your dependency before sending it to Capgo.
如果你的构建命令不同,你可以在这里修改它 build_code 步骤。
如果您需要一个环境变量,请使用 MY_ENV_VAR 并设置 secret 在您的GitHub项目设置中,然后密钥然后GitHub Action。
要使Capgo上传工作,您需要获取您的API密钥Capgo,并将其添加到 您的GitHub仓库中的密钥 作为 CAPGO_TOKEN.
您现在可以提交这两个文件并看到您的第一个版本出现在Capgo中!
添加提交将生成一个新的Capacitor生产和开发频道的构建。
您应该在Ionic构建步骤中添加您的测试,以确保您的code正在工作。
前往您的Capgo控制台并检查刚刚出现的构建,您现在有了您的CI/CD系统。
继续从使用GitHub Actions管理开发和生产构建
If you are using 使用 GitHub 来管理开发和生产环境的构建 若要规划渠道路由和阶段性发布,需要将其连接到 渠道 若要了解渠道的实现细节,请参阅 渠道 若要了解渠道的实现细节,请参阅 渠道 若要了解渠道的实现细节,请参阅 Beta 测试解决方案 若要了解产品工作流程,请参阅 版本目标解决方案 为产品工作流程在版本目标解决方案中使用。