Repository navigation
feat: Claude Code の自動バージョン更新ワークフローを追加 #550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| name: Update Claude Code Version | ||
|
|
||
| on: | ||
| schedule: | ||
| # 毎日 UTC 4:00(JST 13:00)に実行 | ||
| - cron: '0 4 * * *' | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
|
|
||
| - 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 | ||
|
Comment on lines
+28
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result:
Sources Citations: Replace npm-based version check with the native installer, which supports explicit versioning. The workflow reads the version from npm's
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 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Summary | ||
| run: | | ||
| if [ "${{ steps.versions.outputs.needs_update }}" == "true" ]; then | ||
| echo "✅ PR created to update Claude Code from ${{ steps.versions.outputs.current }} to ${{ steps.versions.outputs.latest }}" | ||
| else | ||
| echo "ℹ️ Claude Code is already at the latest version (${{ steps.versions.outputs.current }})" | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current-version parser only accepts digits and dots, so versions like
2.2.0-beta.1or2.2.0+buildare truncated before comparison. In that caseneeds_updatestays true forever and the latersedreplacement 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 👍 / 👎.