Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM mcr.microsoft.com/devcontainers/base:2.0-ubuntu-24.04

# Build arguments
ARG CLAUDE_CODE_OAUTH_TOKEN

Check warning on line 4 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Trivy Container Scan

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "CLAUDE_CODE_OAUTH_TOKEN") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 4 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Generate SBOM

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "CLAUDE_CODE_OAUTH_TOKEN") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ARG ANTHROPIC_API_KEY

Check warning on line 5 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Trivy Container Scan

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "ANTHROPIC_API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 5 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Generate SBOM

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "ANTHROPIC_API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ARG IMAGE_VERSION="dev"

# OCI Image Labels for version tracking
Expand Down Expand Up @@ -100,8 +100,10 @@

# Install Claude Code using native installer (npm installation deprecated)
# Must run as vscode user so claude installs to /home/vscode/.claude/local/bin
# Version is managed by .github/workflows/update-claude-code.yml
ARG CLAUDE_CODE_VERSION=2.1.71
USER vscode
RUN curl -fsSL https://claude.ai/install.sh | bash -s 2.1.63 \
RUN curl -fsSL https://claude.ai/install.sh | bash -s "${CLAUDE_CODE_VERSION}" \
&& echo 'export PATH="$HOME/.claude/local/bin:$PATH"' >> /home/vscode/.bashrc
ENV PATH="/home/vscode/.claude/local/bin:${PATH}"
USER root
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/update-claude-code.yml
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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.sh installer accepts a version argument (passed to bash -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.


- 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
Loading