1- name : Build and Publish Docker Images
1+ name : Build and Release Docker Images
22
33on :
44 push :
77 paths :
88 - ' Dockerfile*'
99 - ' scripts/docker-entrypoint.sh'
10- - ' .github/workflows/build-and-publish .yml'
10+ - ' .github/workflows/build-and-release .yml'
1111 - ' .dockerignore'
12+ - ' versions.json'
1213 pull_request :
1314 branches : [ main ]
1415 paths :
1516 - ' Dockerfile*'
1617 - ' scripts/docker-entrypoint.sh'
17- - ' .github/workflows/build-and-publish .yml'
18+ - ' .github/workflows/build-and-release .yml'
1819 - ' .dockerignore'
1920 workflow_dispatch :
2021 inputs :
@@ -353,4 +354,66 @@ jobs:
353354
354355 # Test Python SDK is installed
355356 docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.number }}-alpine-python \
356- python3 -c "import claude_agent_sdk; print('Alpine Python SDK installed')"
357+ python3 -c "import claude_agent_sdk; print('Alpine Python SDK installed')"
358+
359+ release :
360+ needs : [build-typescript, build-python, build-alpine, build-alpine-python]
361+ if : github.event_name == 'push' && github.ref == 'refs/heads/main' && always()
362+ runs-on : ubuntu-latest
363+ permissions :
364+ contents : write
365+
366+ steps :
367+ - name : Checkout repository
368+ uses : actions/checkout@v4
369+ with :
370+ fetch-depth : 2
371+
372+ - name : Check if versions changed
373+ id : versions
374+ run : |
375+ if git diff HEAD~1 --name-only | grep -q '^versions.json$'; then
376+ echo "changed=true" >> $GITHUB_OUTPUT
377+ else
378+ echo "changed=false" >> $GITHUB_OUTPUT
379+ fi
380+
381+ - name : Create release
382+ if : steps.versions.outputs.changed == 'true'
383+ env :
384+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
385+ run : |
386+ # Read versions
387+ CLI_VERSION=$(jq -r '."claude-code-cli"' versions.json)
388+ SDK_VERSION=$(jq -r '."claude-agent-sdk-cli"' versions.json)
389+ PYTHON_VERSION=$(jq -r '."claude-agent-sdk-python"' versions.json)
390+ DATE=$(jq -r '.last_updated' versions.json)
391+
392+ # Determine tag (handle same-day duplicates)
393+ TAG="${DATE}"
394+ SUFFIX=1
395+ while git tag -l "$TAG" | grep -q .; do
396+ TAG="${DATE}.${SUFFIX}"
397+ SUFFIX=$((SUFFIX + 1))
398+ done
399+
400+ # Build release notes
401+ NOTES="## SDK Versions"
402+ NOTES+=$'\n\n'"| Package | Version |"
403+ NOTES+=$'\n'"| --- | --- |"
404+ NOTES+=$'\n'"| \`@anthropic-ai/claude-code\` (CLI) | ${CLI_VERSION} |"
405+ NOTES+=$'\n'"| \`@anthropic-ai/claude-agent-sdk\` (TS SDK) | ${SDK_VERSION} |"
406+ NOTES+=$'\n'"| \`claude-agent-sdk\` (Python SDK) | ${PYTHON_VERSION} |"
407+ NOTES+=$'\n\n'"## Docker Images"
408+ NOTES+=$'\n\n'"Pull the latest:"
409+ NOTES+=$'\n'"\`\`\`bash"
410+ NOTES+=$'\n'"docker pull ghcr.io/cabinlab/claude-code-sdk-docker:typescript"
411+ NOTES+=$'\n'"docker pull ghcr.io/cabinlab/claude-code-sdk-docker:python"
412+ NOTES+=$'\n'"docker pull ghcr.io/cabinlab/claude-code-sdk-docker:alpine"
413+ NOTES+=$'\n'"docker pull ghcr.io/cabinlab/claude-code-sdk-docker:alpine-python"
414+ NOTES+=$'\n'"\`\`\`"
415+
416+ gh release create "$TAG" \
417+ --title "SDK Update ${TAG}" \
418+ --notes "$NOTES" \
419+ --latest
0 commit comments