Skip to content

Commit 3cc493e

Browse files
Aut-increment version and release
1 parent 8cf220c commit 3cc493e

File tree

2 files changed

+90
-4
lines changed

2 files changed

+90
-4
lines changed

.claude/settings.local.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
{
22
"permissions": {
33
"allow": [
4-
"Bash(gh issue view:*)",
5-
"Bash(gh issue create:*)",
6-
"Bash(gh issue close:*)",
7-
"Bash(uv run:*)"
4+
"Bash(*)",
5+
"Search",
6+
"Fetch",
7+
"WebFetch",
8+
"Find",
9+
"Explore",
10+
"Edit",
11+
"Read",
12+
"Write"
813
]
914
}
1015
}

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
release:
12+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Generate token for version incrementer app
16+
id: create_token
17+
uses: tibdex/github-app-token@v2
18+
with:
19+
app_id: ${{ secrets.APP_ID }}
20+
private_key: ${{ secrets.PRIVATE_KEY }}
21+
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
ref: ${{ github.sha }}
27+
token: ${{ steps.create_token.outputs.token }}
28+
29+
- name: Force correct branch on workflow sha
30+
run: git checkout -B ${{ github.ref_name }} ${{ github.sha }}
31+
32+
- name: Bump patch version
33+
id: bump
34+
run: |
35+
CURRENT_VERSION=$(grep -oP '^version = "\K[^"]+' pyproject.toml)
36+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
37+
NEW_PATCH=$((PATCH + 1))
38+
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
39+
sed -i "s/^version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" pyproject.toml
40+
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
41+
echo "tag=v$NEW_VERSION" >> "$GITHUB_OUTPUT"
42+
echo "Bumped version: $CURRENT_VERSION -> $NEW_VERSION"
43+
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v5
46+
47+
- name: Sync uv lockfile
48+
run: uv lock
49+
50+
- name: Get merged PR info
51+
id: pr_info
52+
env:
53+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
run: |
55+
PR_NUMBER=$(gh pr list --state merged --search "${{ github.sha }}" --json number --jq '.[0].number' 2>/dev/null || echo "")
56+
if [ -n "$PR_NUMBER" ]; then
57+
PR_BODY=$(gh pr view "$PR_NUMBER" --json body --jq '.body')
58+
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
59+
{
60+
echo "notes<<EOF"
61+
echo "$PR_BODY"
62+
echo "EOF"
63+
} >> "$GITHUB_OUTPUT"
64+
else
65+
echo "notes=Release ${{ steps.bump.outputs.tag }}" >> "$GITHUB_OUTPUT"
66+
fi
67+
68+
- name: Create GitHub release
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
gh release create "${{ steps.bump.outputs.tag }}" \
73+
--title "${{ steps.bump.outputs.tag }}" \
74+
--notes "${{ steps.pr_info.outputs.notes }}"
75+
76+
- name: Commit version bump
77+
uses: stefanzweifel/git-auto-commit-action@v5
78+
with:
79+
commit_message: "chore: release ${{ steps.bump.outputs.tag }} [skip ci]"
80+
branch: ${{ github.ref_name }}
81+
file_pattern: "pyproject.toml uv.lock"

0 commit comments

Comments
 (0)