Skip to content

Commit 45654bb

Browse files
Merge pull request #6 from Chintanpatel24/workflow-version-bump
feat: auto version bump on release
2 parents d6bc06a + 1234c39 commit 45654bb

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/bump-version.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Bump Version on Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
bump-version:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
ref: main
17+
fetch-depth: 0
18+
19+
- name: Extract version
20+
id: extract_version
21+
run: |
22+
# Remove leading 'v' if present (e.g., 'v2.1.0' -> '2.1.0')
23+
VERSION="${{ github.event.release.tag_name }}"
24+
VERSION="${VERSION#v}"
25+
echo "version=$VERSION" >> $GITHUB_OUTPUT
26+
27+
- name: Update version in files
28+
run: |
29+
VERSION="${{ steps.extract_version.outputs.version }}"
30+
echo "Bumping version to $VERSION"
31+
32+
# Update pyproject.toml
33+
sed -i -E "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
34+
35+
# Update src/fiver/__init__.py
36+
sed -i -E "s/^__version__ = \".*\"/__version__ = \"$VERSION\"/" src/fiver/__init__.py
37+
38+
- name: Commit and push changes
39+
run: |
40+
VERSION="${{ steps.extract_version.outputs.version }}"
41+
42+
git config --global user.name "github-actions[bot]"
43+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
44+
45+
git add pyproject.toml src/fiver/__init__.py
46+
47+
# Check if there are any changes to commit
48+
if git diff --staged --quiet; then
49+
echo "Version is already up-to-date."
50+
else
51+
git commit -m "chore: bump version to $VERSION [skip ci]"
52+
git push origin main
53+
fi

0 commit comments

Comments
 (0)