Skip to content

Merge pull request #11 from Wirasm/changelog-v0.4.0 #20

Merge pull request #11 from Wirasm/changelog-v0.4.0

Merge pull request #11 from Wirasm/changelog-v0.4.0 #20

name: Update Changelog and Version
on:
push:
branches:
- main
workflow_dispatch: # Allows manual triggering
jobs:
update-changelog-and-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install Claude Code CLI
run: |
npm install -g @anthropic-ai/claude-code
echo "Claude Code installed successfully"
- name: Setup GitHub CLI
run: |
# GitHub CLI is pre-installed on GitHub Actions runners
gh --version
- name: Update Changelog and Create PR
run: |
# Run Claude to update changelog, version, and create a PR
claude -p "You are tasked with updating the changelog, bumping the version, and creating a PR for this project.
Please follow these steps:
1. Analyze the git commit history to understand the changes that were pushed to main:
- Use git commands to view the recent commits
- Determine if these changes are features, bug fixes, or breaking changes
- Based on semantic versioning principles, decide whether to bump the major, minor, or patch version
2. Check if CHANGELOG.md exists. If not, create it with proper headers following the Keep a Changelog format.
3. Read the current version from pyproject.toml and determine the new version:
- Only bump the major version if its explicitly mentioned in the commit history
- If you found new features but no breaking changes, bump the minor version
- If you found only bug fixes, documentation updates, or other minor changes, bump the patch version
4. Update the version in:
- pyproject.toml
- src/__init__.py if it exists
5. Add a new section to the changelog with:
- The new version number and today's date
- A summary of changes, categorized by type (Features, Bug Fixes, Documentation, etc.)
6. Create a new branch named 'changelog-vX.Y.Z' (using the new version number)
7. Commit your changes to this branch with a descriptive commit message
8. Create a pull request using the GitHub CLI:
- Use 'gh pr create' to create the PR
- Set the title to 'Update changelog and bump version to X.Y.Z'
- Include a summary of changes in the PR description
- Add an appropriate label if available
- IMPORTANT: DO NOT JUST PROVIDE THE URL or SUGGEST MANUAL CREATION - YOU MUST USE 'gh pr create' TO AUTOMATICALLY CREATE THE PR
9. Finally, print the URL of the created PR or a message indicating no changes were needed.
Note that GitHub CLI (gh) is already authenticated with appropriate permissions in this environment, so you can use it directly.
To create a PR, use a command like:
gh pr create --title \"Update changelog and bump version to X.Y.Z\" --body \"## Summary\\n- Key changes...\" --base main --head your-branch-name
This will automatically create the PR and return its URL." \
--allowedTools "Read" "Write" "Edit" "Bash" "Bash(git:*)" "Bash(gh:*)"