CI/CD統合
このプラグインのインストール手順とフルマークダウンガイドを含む設定プロンプトをコピーする。
Integrating Capgo into your CI/CD pipeline allows you to fully automate the process of building and deploying updates to your app. By leveraging the Capgo CLI and semantic-release, you can ensure consistent, reliable deployments and enable rapid iteration.
CI/CD統合の利点
CI/CD統合の利点-
自動化: 人間のエラーをなくし、手動のステップをなくすことができます。ビルド、テスト、デプロイプロセスはすべて自動化できます。
-
一貫性: Every deployment follows the same set of steps, ensuring a predictable and repeatable process. This is especially valuable when you have multiple team members contributing code.
-
迅速な開発: 自動化されたデプロイにより、信頼性の高い更新を頻繁に実施できます。手動のQAやリリース承認を待つ必要がなくなります。
Capgo CLI
「Capgo CLI」CI/CDのCapgo CLIは、CapgoをCI/CDフローに統合するための鍵となります。新しいバンドルバージョンのプッシュ、チャンネルの管理など、コマンドを提供します。
CI/CD統合の最も重要なコマンドは bundle upload:
npx @capgo/cli@latest bundle upload --channel Production --apikey YOUR_API_KEY暗号化を使用している場合、次のいずれかから提供する必要があります:
プライベートキーファイルパスを使用:
npx @capgo/cli@latest bundle upload --channel Production --apikey YOUR_API_KEY --key-v2 PRIVATE_KEY_PATHターミナル画面
npx @capgo/cli@latest bundle upload --channel Production --apikey YOUR_API_KEY --key-data-v2 PRIVATE_KEY_CONTENTCI/CDのための環境変数を使用する(CI/CDのベストプラクティス):
npx @capgo/cli@latest bundle upload --channel Production --apikey YOUR_API_KEY --key-data-v2 "$CAPGO_PRIVATE_KEY"暗号化用の環境変数の設定
「暗号化用の環境変数の設定」のセクションCI/CD環境では、プライベートキーをファイルではなく環境変数として保存することをお勧めします。設定方法はこちらです。
-
プライベートキー内容を取得:
ターミナル画面 cat .capgo_key_v2 | pbcopyこのコマンドは、キーの内容をクリップボードにコピーします。
-
CI/CD環境に追加:
- GitHub アクション: 追加
CAPGO_PRIVATE_KEYリポジトリのシークレットに追加 - GitLab CI: プロジェクト設定でマスクされた変数として追加
- CircleCI: プロジェクト設定で環境変数として追加
- Jenkins: 秘密のテキスト認証情報として追加
- GitHub アクション: 追加
-
パイプラインで使用する
- run: npx @capgo/cli@latest bundle upload --channel=production --apikey=${{ secrets.CAPGO_API_KEY }} --key-data-v2 "${{ secrets.CAPGO_PRIVATE_KEY }}"
注意: The --key-data-v2 CI/CDパイプラインで環境変数を使用する場合、臨時ファイルを作成したくない場合は、プライベートキー内容を直接文字列として渡すことができます。
このコマンドは、指定されたチャンネルに現在のWebビルドをアップロードします。通常、CI/CDパイプラインの最後のステップとして実行します。Webビルドが正常に完了した後です。
CI/CDパイプラインにCapgoを設定する
セクションのタイトル「CI/CDパイプラインにCapgoを設定する」CI/CDツールの選択に応じて、具体的な手順は異なりますが、Capgoの統合の一般的なプロセスは次のようになります。
-
APIキーを生成する: Capgoダッシュボードにログインし、APIキーを作成します。このキーは、CI/CD環境でCLIを認証するために使用されます。秘密に保ち、リポジトリにコミットしないでください!
-
コマンドを設定する
bundle uploadコマンド: CI/CD構成にステップを追加して、適切な引数でコマンドを実行します。bundle upload__CAPGO_KEEP_0__\n置き換えupload.yml - run: npx @capgo/cli@latest bundle upload --channel=production --apikey=${{ secrets.CAPGO_API_KEY }}Productionデプロイ先のチャンネルに置き換え、${{ secrets.CAPGO_API_KEY }}APIキーを保持する環境変数に置き換え、--key-data-v2 "${{ secrets.CAPGO_PRIVATE_KEY }}"暗号化を使用する場合に追加します。 -
このステップは、Webビルド後に追加してください。
upload: Webビルドが正常に完了した後、このステップが実行されるようにしてください。これにより、常に最新の__CAPGO_KEEP_0__をデプロイすることが保証されます。uploadstep comes after your web build has completed successfully. This ensures you’re always deploying your latest code.\n Here’s an example configuration for GitHub Actions:\nupload.yml name: Deploy to Capgoon:push:branches: [main]jobs:deploy:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v6- uses: actions/setup-node@v6with:node-version: '24'- run: npm ci- run: npm run build- run: npm install -g @capgo/cli- run: npx @capgo/cli@latest bundle upload --channel=production --apikey=${{ secrets.CAPGO_API_KEY }} --key-data-v2 "${{ secrets.CAPGO_PRIVATE_KEY }}"
バージョン管理のためのSemantic-release
バージョン管理のためのSemantic-releaseのセクションCapacitorのバージョンを管理するには、Capgoを使用して、バージョンをファイルに設定することをお勧めします。 capacitor.config.ts バージョンをファイルに設定するには、 package.json:
import pkg from './package.json'
const config: CapacitorConfig = { // ... other config plugins: { CapacitorUpdater: { version: pkg.version, } }}このアプローチにより、次のことが可能になります:
- semantic-release (または他のツール)を使用してバージョンを更新する
package.jsonバージョン - 更新されたバージョンを自動的に含むアプリをビルドする
- 正しいバージョンを持つバンドルをアップロードする
CI/CDワークフローは次のようになります:
- run: npm ci- run: npx semantic-release # Updates package.json version- run: npm run build # Builds with new version from capacitor.config- run: npx @capgo/cli@latest bundle upload --channel=production --apikey=${{ secrets.CAPGO_API_KEY }}サンプル .releaserc semantic-release用の設定ファイルです:
{ "branches": [ "main", { "name": "beta", "prerelease": true } ], "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", "@semantic-release/changelog", [ "@semantic-release/git", { "assets": ["CHANGELOG.md", "package.json"], "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" } ] ]}この設定は以下を実行します:
- コミットメッセージを分析して、次のバージョン番号を決定します。Conventional Commits specに従います。
- リリースノートを、最後のリリース以降のコミットに基づいて生成します。
- __CAPGO_KEEP_0__.configが新しいリリースノートを取得するように更新します。
CHANGELOG.md__CAPGO_KEEP_0__.configのバージョンを更新します。 - リポジトリに更新された、__CAPGO_KEEP_0__.configとその他の変更ファイルをコミットします。
package.jsonversion, which will be picked up by your capacitor.config. - Commits the updated
CHANGELOG.md,package.json, and any other changed files back to the repository.
アプリをビルドする前に、semantic-releaseを実行してください。更新されたバージョンが__CAPGO_KEEP_0__.configを通じてビルドに含まれるようにします。 package.json capacitor.configを通じてビルドに含まれるようにします。
ローカルバージョンがすでにCapgoの場合、自動的にバージョンを上げます。
「ローカルバージョンがすでにCapgoの場合、自動的にバージョンを上げる」セクションバンドル名は一意でなければなりません (削除されたバージョンはまだその名前を占有しています)。CIが同じバージョンを繰り返しアップロードするとアップロードは失敗します。バージョンを上げるのではなく、__CAPGO_KEEP_0__を利用してください (たとえば、semantic-releaseを使用)。そうでない場合は、チャンネルのリンクされたバンドルから次のフリーセーミバージョンを選択するか、またはリモートアプリの最新バージョンを選択します: package.json ターミナル画面 package.json (for example with semantic-release). When that is not practical, let the CLI pick the next free semver from the channel’s linked bundle, or else the latest remote app version:
npx @capgo/cli@latest bundle upload --channel=production --auto-bumpnpx @capgo/cli@latest bundle upload --auto-bump majornpx @capgo/cli@latest bundle upload --auto-bump minor # default when the flag has no valuenpx @capgo/cli@latest bundle upload --auto-bump patch # alias: fixnpx @capgo/cli@latest bundle upload --auto-bump metadatanpx @capgo/cli@latest bundle upload --channel=production --auto-bump ai--auto-bump ai uses Capgo Cloudflare Workers AI to compare local bundle files against the previous Capgo/channel delta manifest, pick major | minor | patch | metadata, and print a short reason. With no previous Capgo version, AI is skipped and the bump is patch.
組み合わせないでください。 --auto-bump と --bundle / -b. 最新のオプションのリストについては、 bundle upload 参照 トラブルシューティング
トラブルシューティング
問題が発生した場合は、以下の点を確認してください。If you encounter issues with your Capgo CI/CD integration, here are a few things to check:
-
API key: Ensure your API key is valid and has the necessary permissions. If using an environment variable, double check that it’s set correctly.
-
CLI version: Make sure you’re using the latest version of the Capgo CLI. Older versions may have compatibility issues or lack certain features.
-
ビルドアーティファクト: Confirm that your web build is generating the expected output files. The Capgo CLI needs a valid web build to create a bundle.
-
ネットワーク接続性: Check that your CI/CD environment has network access to the Capgo servers. Firewall or proxy issues can sometimes interfere with the
uploadコマンド
If you’re still having trouble, reach out to Capgo support for assistance. They can help troubleshoot any issues with your specific setup.
Integrating Capgo into your CI/CD pipeline with proper version management can greatly streamline your development workflow. By automating your deployments and versioning through the capacitor.config approach, you can ship updates faster and with more confidence.
: CI/CDパイプラインにCapgoを適切にバージョン管理することで、開発ワークフローが大幅にスムーズになります。Capgo.configアプローチを使用して、自動化されたデプロイとバージョニングを実現し、更新を迅速かつ自信を持ってリリースすることができます。 capacitor.config.ts バージョン package.json : バージョンをファイルに設定し、semantic-releaseを使用して更新することをお勧めします。
詳細については、Capgo CLI コマンドとオプションを参照してください。 CLI リファレンス. また、シームアーリーリリースの設定については、シームアーリーリリースドキュメントを参照してください。 シームアーリーリリースドキュメント.
CI/CDを楽しみましょう!
CI/CD統合から続きましょう。
CI/CD統合コンテキスト: Capgo Builder / ネイティブクラウドビルド製品ページ。役割: 短いUIラベルまたはナビゲーションアイテム。メッセージキー `native_build_feature_ci_cd` (ネイティブビルド機能Ci Cd)。 CI/CD統合 CI/CD Capgo CI/CD for the product workflow in Capgo CI/CD, Capgoネイティブビルド Capgo製品ワークフロー向けのネイティブビルド Capgo統合 Capgo製品ワークフロー向けの統合 GitHubアクション統合 GitHubアクション統合の実装詳細 GitLab CI/CD統合 __CAPGO_KEEP_0__アクション統合の実装詳細