Skip to content

feat: per-plugin cost trend + threshold warnings (closes #201) #260

feat: per-plugin cost trend + threshold warnings (closes #201)

feat: per-plugin cost trend + threshold warnings (closes #201) #260

name: Auto-release on [RELEASE] merge
on:
pull_request:
types: [closed]
branches: [main]
jobs:
release:
name: Bump version & publish to PyPI
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, '[RELEASE]') && github.actor == 'vivekchand'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build tools
run: pip install build twine
- name: Bump patch version
id: bump
run: |
# Always bump from latest PyPI version — never from dashboard.py which
# can be stale when multiple [RELEASE] PRs merge in quick succession
OLD=$(curl -s https://pypi.org/pypi/clawmetry/json | python3 -c "import json,sys; print(json.load(sys.stdin)['info']['version'])")
MAJOR=$(echo $OLD | cut -d. -f1)
MINOR=$(echo $OLD | cut -d. -f2)
PATCH=$(echo $OLD | cut -d. -f3)
NEW="$MAJOR.$MINOR.$((PATCH + 1))"
sed -i "s/__version__ = \".*\"/__version__ = \"$NEW\"/" dashboard.py
echo "old=$OLD" >> $GITHUB_OUTPUT
echo "new=$NEW" >> $GITHUB_OUTPUT
echo "Bumped $OLD → $NEW"
- name: Build package
run: python3 -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload --skip-existing dist/*
- name: Create GitHub release tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.bump.outputs.new }}" \
--title "v${{ steps.bump.outputs.new }}" \
--notes "Released via PR: ${{ github.event.pull_request.title }}" \
--latest || echo "Release tag already exists, skipping"
- name: Commit version bump directly to main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add dashboard.py
git commit -m "chore: bump to v${{ steps.bump.outputs.new }} [skip ci]"
# Rebase on top of any commits that landed while we were building/publishing
git pull --rebase origin main
git push origin main