rust-node-ci について
rust-node-ciは、RustとNode.jsを組み合わせたプロジェクト向けのGitHub Actionsワークフローと複合アクションを提供します。テンプレートを使い、CIやクロスプラットフォームビルド、npm公開を構成できます。
主な機能
- 01RustとNode.jsのCIワークフロー
- 02セットアップ・ビルド用複合アクション
- 03クロスプラットフォームのバイナリビルド
- 04アーティファクトのアップロードと取得
- 05開発版・リリース版のバージョン管理
活用シーン
- 01RustとNode.jsのリポジトリでCIを開始
- 02プラットフォーム別ビルドと成果物処理の追加
- 03プラットフォームパッケージのnpm公開
- 04キャッシュやワークフローの問題調査
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ onsager-ai/ dev-skills --skill rust-node-ciインストール後、Claude Code で/rust-node-ciを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/troubleshooting.mdtemplates/actions/compute-version/action.ymlREADME.mdtemplates/actions/rust-cross-build/action.ymlREADME.mdtemplates/actions/setup-workspace/action.ymlREADME.mdtemplates/actions/wait-npm-propagation/action.ymlREADME.mdtemplates/workflows/ci.ymlcopilot-setup-steps.ymlpublish.yml詳細
Rust+Node.js CI/CD
Rust+Node.js ハイブリッドプロジェクト向けの GitHub Actions ワークフローとコンポジットアクションです。
このスキルを使う場面
次のいずれかに該当する場合に有効化します。
Cargo.tomlとpackage.jsonの両方があるリポジトリで.github/workflows/を扱う場合- CI/CD パイプラインを設定、修正、または拡張する場合
- プロジェクトにコンポジットアクションをインストールする場合
- ユーザーが「CI」「workflow」「GitHub Actions」「cross-build」「artifact」に言及した場合
判断ツリー
What does the user need?
Set up CI from scratch?
→ Copy templates/workflows/ into .github/workflows/
→ Install composite actions from templates/actions/ into .github/actions/
→ Customize platform matrix for your targets
Fix a failing CI job?
→ Node job → CI Jobs section
→ Rust build/cross-compile → Composite Actions section + references/troubleshooting.md
→ Publish workflow → see rust-npm-publish skill
Add a new platform to the build matrix?
→ Publish Workflow Matrix section
→ Full platform reference → see rust-npm-publish skill
Understand dev vs release versioning in CI?
→ Dev Versioning section
ワークフローのアーキテクチャ
┌─────────────┐ ┌──────────────────┐
│ Node Build │ │ Rust Build │
│ (test/lint) │ │ (per platform) │
└──────┬──────┘ └────────┬─────────┘
│ │
│ ┌─────────────┐ │
└──►│ Artifacts │◄──┘
└──────┬──────┘
│
┌──────▼──────┐
│ Publish │
└─────────────┘
ワークフロー
| ワークフロー | トリガー | 実行内容 |
|---|---|---|
ci.yml | PR、main への push | Node のビルド+テスト+lint、Rust の fmt+clippy+テスト |
publish.yml | リリース、dispatch | クロスビルド → npm への公開 |
copilot-setup-steps.yml | repository_dispatch | Copilot エージェントのオンボーディング |
テンプレート:templates/workflows/
CI ジョブ
Node ジョブ
steps:
- uses: ./.github/actions/setup-workspace
- run: pnpm build
- run: pnpm test
- run: pnpm typecheck
Rust ジョブ
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- run: cargo fmt --all -- --check
- run: cargo clippy --workspace -- -D warnings
- run: cargo test --workspace
コンポジットアクション
プロジェクトの .github/actions/<name>/action.yml にインストールし、uses: ./.github/actions/<name> として参照します。
テンプレート:templates/actions/
| アクション | インストール先 | 目的 |
|---|---|---|
setup-workspace | .github/actions/setup-workspace/ | Checkout + pnpm + Node.js + キャッシュ + インストール |
rust-cross-build | .github/actions/rust-cross-build/ | ターゲットプラットフォーム向けに Rust バイナリをビルド |
compute-version | .github/actions/compute-version/ | 開発版/リリース版のバージョンと npm タグを算出 |
wait-npm-propagation | .github/actions/wait-npm-propagation/ | プラットフォームパッケージが表示されるまで npm をポーリング |
公開ワークフローのマトリックス
strategy:
matrix:
include:
- { os: macos-latest, target: x86_64-apple-darwin, platform: darwin-x64 }
- { os: macos-latest, target: aarch64-apple-darwin, platform: darwin-arm64 }
- { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu, platform: linux-x64 }
- { os: windows-latest, target: x86_64-pc-windows-msvc, platform: windows-x64 }
各マトリックス項目で rust-cross-build を実行し、バイナリをアーティファクトとしてアップロードします。
アーティファクトの流れ
# Upload from build job (one per platform)
- uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.platform }}
path: target/${{ matrix.target }}/release/my-cli${{ matrix.platform == 'windows-x64' && '.exe' || '' }}
retention-days: 1
# Download in publish job (all platforms)
- uses: actions/download-artifact@v4
with:
pattern: binary-*
path: artifacts/
merge-multiple: false
キャッシュ
| ツール | 方法 |
|---|---|
| pnpm | actions/setup-node@v4 に cache: 'pnpm' を指定 |
| Rust | Swatinem/rust-cache@v2 に shared-key: ${{ matrix.platform }} を指定 |
| Turbo | .turbo パスに対して actions/cache@v4 を使用 |
CI での開発版バージョニング
リリース以外のビルドでは、一意のプレリリースバージョンを算出します。
base version: 0.2.15
compute-version (is-release: false) → 0.2.16-dev.{github_run_id}
npm-tag: dev
compute-version アクションを使用します。
- uses: ./.github/actions/compute-version
id: version
with:
base-version: ${{ steps.pkg.outputs.version }}
is-release: ${{ github.event_name == 'release' }}
# outputs: version, npm-tag, is-dev
トラブルシューティング
| 問題 | 対処方法 |
|---|---|
| macOS ARM で Rust ビルドが失敗する | macos-latest を使用し、rustup target add aarch64-apple-darwin を実行 |
| pnpm のロックファイルが一致しない | CI では --frozen-lockfile を使用し、ローカルで再生成 |
| Cargo キャッシュが大きすぎる | rust-cache に shared-key を追加し、main でのみ save-if を使用 |
| 後続処理でアーティファクトが見つからない | needs: の連鎖を確認し、アーティファクト名が一致することを確認 |
詳しい診断については、references/troubleshooting.md を参照してください。
テンプレート
| ディレクトリ | 内容 |
|---|---|
| templates/workflows/ | ci.yml、publish.yml、copilot-setup-steps.yml |
| templates/actions/ | action.yml と README を含む4つのコンポジットアクション |
セットアップと有効化
npx skills add -g onsager-ai/dev-skills --skill rust-node-ci -a claude-code -y
Rust+Node.js リポジトリに .github/workflows/ ディレクトリがある場合、またはユーザーが「CI」「workflow」「GitHub Actions」「cross-build」に言及した場合に自動的に有効化されます。
コメント
Markdown 対応