feat: Claude Code の自動バージョン更新ワークフローを追加 - #550
Conversation
- Dockerfile でバージョンを ARG で管理するように変更 - Claude Code を 2.1.63 → 2.1.71 に更新 - update-claude-code.yml ワークフローを追加 - 毎日 UTC 4:00 に最新バージョンをチェック - 新しいバージョンがあれば自動で PR を作成 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR automates Claude Code version management by introducing a build argument in the dev container Dockerfile and adding a GitHub Actions workflow that periodically checks npm for updates, creating pull requests when newer versions are available. Changes
Sequence DiagramsequenceDiagram
actor Schedule
participant Workflow as GitHub Actions<br/>(Workflow)
participant npm as npm Registry
participant Git as Git/GitHub
participant File as Dockerfile
Schedule->>Workflow: Trigger (daily or manual)
Workflow->>Git: Checkout repository
Workflow->>File: Read current CLAUDE_CODE_VERSION
Workflow->>npm: Query `@anthropic-ai/claude-code` latest
Workflow->>Workflow: Compare versions
alt Update Needed
Workflow->>File: Update CLAUDE_CODE_VERSION build arg
Workflow->>Git: Create branch (fix/update-claude-code-*)
Workflow->>Git: Commit and push changes
Workflow->>Git: Create PR with dependencies label
Workflow->>Git: Delete branch after PR creation
else Already Latest
Workflow->>Workflow: Report no update needed
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 AI Code Review (Local Hook)Models: Codex (default) / Gemini (default) 🤖 Codex Review指摘事項なし。 判定: patch is correct ✨ Gemini Reviewレビュー結果は以下の通りです。 指摘事項
総合評価
🤖 Generated by post_pr_ai_review.py hook |
🔍 AI Code Review (Local Hook)Models: Codex (default) / Gemini (default) 🤖 Codex Review指摘事項
判定: patch is incorrect ✨ Gemini Reviewレビュー結果発見事項リスト
全体的な判定patch is incorrect
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5254dcb7d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| id: versions | ||
| run: | | ||
| # 現在のバージョンを Dockerfile から取得 | ||
| CURRENT_VERSION=$(grep -oP 'CLAUDE_CODE_VERSION=\K[0-9.]+' .devcontainer/Dockerfile) |
There was a problem hiding this comment.
Parse full semver for CLAUDE_CODE_VERSION
The current-version parser only accepts digits and dots, so versions like 2.2.0-beta.1 or 2.2.0+build are truncated before comparison. In that case needs_update stays true forever and the later sed replacement can produce an invalid version string (for example by replacing only the prefix and leaving the suffix behind), which breaks the auto-update workflow when upstream publishes non-plain semver tags.
Useful? React with 👍 / 👎.
PR レビュー全体的に良い取り組みです。Claude Code のバージョン管理を自動化することで、手動更新の手間を削減できます。 ✅ 良い点
|
| 項目 | 評価 |
|---|---|
| 設計 | ✅ 良好 |
| sed の正規表現 | |
| シェルインジェクション対策 | |
| エラーハンドリング | 💡 改善余地あり |
主要な修正点は sed のエスケープとシェルインジェクション対策の2点です。それ以外は概ね問題ありません。
🤖 Reviewed by Claude Code
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/update-claude-code.yml:
- Around line 28-79: The workflow currently sets LATEST_VERSION by running `npm
view `@anthropic-ai/claude-code` version` (in the "Get current and latest
versions" step) but the Dockerfile uses the native installer; replace the
npm-based lookup with a call to the native installer's release source (or GitHub
release tag) to populate LATEST_VERSION (keeping the CURRENT_VERSION extraction
from the Dockerfile and the existing outputs like steps.versions), and update
the sed replacement/branch naming logic to use that value; alternatively (or
additionally) add a new step before "Create pull request" that performs a Docker
build/install validation using the retrieved LATEST_VERSION to ensure the
installer and Dockerfile version match before opening the PR.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9d8b420e-c8ea-422b-8f14-32a3bbfea7fc
📒 Files selected for processing (2)
.devcontainer/Dockerfile.github/workflows/update-claude-code.yml
| - name: Get current and latest versions | ||
| id: versions | ||
| run: | | ||
| # 現在のバージョンを Dockerfile から取得 | ||
| CURRENT_VERSION=$(grep -oP 'CLAUDE_CODE_VERSION=\K[0-9.]+' .devcontainer/Dockerfile) | ||
| echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| # 最新バージョンを npm から取得 | ||
| LATEST_VERSION=$(npm view @anthropic-ai/claude-code version) | ||
| echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT | ||
|
|
||
| echo "Current version: $CURRENT_VERSION" | ||
| echo "Latest version: $LATEST_VERSION" | ||
|
|
||
| # 更新が必要かチェック | ||
| if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then | ||
| echo "needs_update=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "needs_update=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Update Dockerfile | ||
| if: steps.versions.outputs.needs_update == 'true' | ||
| run: | | ||
| sed -i "s/CLAUDE_CODE_VERSION=${{ steps.versions.outputs.current }}/CLAUDE_CODE_VERSION=${{ steps.versions.outputs.latest }}/" .devcontainer/Dockerfile | ||
| echo "Updated Claude Code version from ${{ steps.versions.outputs.current }} to ${{ steps.versions.outputs.latest }}" | ||
|
|
||
| - name: Create pull request | ||
| if: steps.versions.outputs.needs_update == 'true' | ||
| uses: peter-evans/create-pull-request@v7 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| branch: fix/update-claude-code-${{ steps.versions.outputs.latest }} | ||
| delete-branch: true | ||
| commit-message: 'fix: update Claude Code to ${{ steps.versions.outputs.latest }}' | ||
| title: 'fix: update Claude Code to ${{ steps.versions.outputs.latest }}' | ||
| body: | | ||
| ## Claude Code バージョン更新 | ||
|
|
||
| | 項目 | 値 | | ||
| |------|-----| | ||
| | 現在のバージョン | `${{ steps.versions.outputs.current }}` | | ||
| | 新しいバージョン | `${{ steps.versions.outputs.latest }}` | | ||
|
|
||
| ### 📝 リリースノート | ||
|
|
||
| [Claude Code Releases](https://github.com/anthropics/claude-code/releases/tag/v${{ steps.versions.outputs.latest }}) | ||
|
|
||
| --- | ||
|
|
||
| **Auto-generated by:** [update-claude-code.yml](.github/workflows/update-claude-code.yml) | ||
| labels: dependencies |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Does Claude Code's official installer claude.ai/install.shsupport installing an explicit version, and are versions guaranteed to stay in sync with the npm package@anthropic-ai/claude-code?
💡 Result:
- Yes. Anthropic’s official docs show that the
claude.ai/install.shinstaller accepts a version argument (passed tobash -s), e.g.curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58, explicitly labeled “To install a specific version number.” [1] - No guarantee they stay in sync. Anthropic documents that npm installation is deprecated in favor of the native installer (which auto-updates), and also notes that other distribution channels can lag (“may notify you of updates before the new version is available in these package managers”), implying releases are not guaranteed to land everywhere simultaneously. There’s no statement in the official docs promising the native-installer versioning will always match the npm package
@anthropic-ai/claude-code. [1]
Sources
[1] Anthropic Claude Code docs – Setup / Install & Update (includes “install a specific version number”, “Deprecated npm installation”, and channel lag note) (docs.anthropic.com)
Citations:
Replace npm-based version check with the native installer, which supports explicit versioning.
The workflow reads the version from npm's @anthropic-ai/claude-code package, but the Dockerfile installs Claude via claude.ai/install.sh. The official Anthropic docs indicate that:
- The native installer accepts explicit version parameters (
curl -fsSL https://claude.ai/install.sh | bash -s VERSION) - npm installation is deprecated in favor of the native installer
- Version channels are not guaranteed to stay in sync across distribution channels
Instead of fetching from npm, fetch the version from the native installer's release source and use its versioning directly. Alternatively, add a Docker build/install validation step before the create-pull-request action to catch channel mismatches before opening PRs.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/update-claude-code.yml around lines 28 - 79, The workflow
currently sets LATEST_VERSION by running `npm view `@anthropic-ai/claude-code`
version` (in the "Get current and latest versions" step) but the Dockerfile uses
the native installer; replace the npm-based lookup with a call to the native
installer's release source (or GitHub release tag) to populate LATEST_VERSION
(keeping the CURRENT_VERSION extraction from the Dockerfile and the existing
outputs like steps.versions), and update the sed replacement/branch naming logic
to use that value; alternatively (or additionally) add a new step before "Create
pull request" that performs a Docker build/install validation using the
retrieved LATEST_VERSION to ensure the installer and Dockerfile version match
before opening the PR.
|
(aside) |
|
Claude finished @keito4's task in 5m 38s —— View job CI修正調査結果
📊 現在のCI状態すべてのCIチェックが ✅ パス しています:
コメント投稿時点では Container Security Scan が in_progress 中(Docker イメージビルド+Trivy 脆弱性スキャン実行中)でしたが、現在は正常完了しています。
|
|
🎉 This PR is included in version 1.91.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
ARGで管理するように変更2.1.63→2.1.71に更新update-claude-code.ymlを追加自動更新ワークフローの動作
npm view @anthropic-ai/claude-code versionTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Chores