本教程重点介绍 GitLab CI,但您可以通过一些调整适应任何其他 CI/CD 平台。
前言
请确保您已将应用程序添加到 Capgo,本教程仅关注上传阶段
提交约定
首先,您需要遵循提交约定 上下文:Capgo Builder / 原生云构建产品页面。角色:短 UI 标签或导航项。消息键 `native_build_builder_credit_first` (原生构建构建器首先)。规范提交

规范提交
GitLab CI 通过标签进行创建
创建一个文件在这个路径: .github/workflows/bump_version.yml
内容如下:
name: Bump version
on:
push:
branches:
- main
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
run: npx capacitor-standard-version
- 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
这将为每个提交在主分支发布一个标签。并且在主分支中添加每个提交的变更日志条目。 CHANGELOG.md.
如果你没有这个文件,不用担心,它会自动创建。
为了让这个功能工作,创建一个 个人访问令牌 并将其添加到你的GitLab CI/CD变量中,如 PERSONAL_ACCESS_TOKEN.
这是让CI能够提交变更日志的必要步骤。
当你创建令牌时,请选择 never 并将范围设置为 repo.
最后,要让工具理解你的版本保存在哪里,你需要创建一个文件 .cz.toml 在你的仓库根目录下。
并且在这里添加:
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "$major.$minor.$patch$prerelease"
version = "0.11.5"
version_files = [
"package.json:version",
".cz.toml"
]
将此文件中的版本设置为与您在文件中相同的版本。 package.json 文件。
这只需要第一次,之后工具将自动保持更新。
You can now commit this both files and see your first tag appear in GitHub!
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 run build
env: # Remove both lines if you don't need it
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }} # Example of env var coming from a secret
- name: Create Release
id: create_release
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 要使此功能正常工作,您需要获取您的 Capgo 密钥并将其添加到
To make this work, you need to get your API key for Capgo, add it in the GitHub 的秘密 因为 CAPGO_TOKEN.
您现在可以提交这两个文件并看到第一个标签出现在 GitHub 中!
添加提交将为生产频道生成一个新的构建。
您应该在构建步骤中添加您的测试,以确保您的 code 正常工作。
前往您的 Capgo 控制台并检查刚刚出现的构建,您现在拥有您的 CI/CD 系统。
如果您希望让所有用户在它可用时立即获得更新,请前往您的频道并将其设置为 public.
继续阅读 Automatic build and release with Gitlab
如果您正在使用 Automatic build and release with Gitlab 来规划 CI/CD 自动化,连接它与 Capgo CI/CD 为Capgo产品工作流程中的CI/CD, Capgo原生构建 为Capgo产品工作流程中的原生构建, Capgo集成 for the product workflow in Capgo Integrations, 为__CAPGO_KEEP_0__产品工作流程中的集成, CI/CD集成 GitHub Actions Integration for the implementation detail in GitHub Actions Integration.