Skip to content

Commit 955fabc

Browse files
Add auto dev version bump workflow for develop branch
Mirrors auto-release.yml but for develop: increments .devN suffix on every push to develop (skips version bump commits to avoid loops).
1 parent 71e0f5c commit 955fabc

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Auto Dev Bump on Develop
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths-ignore:
8+
- '.github/**'
9+
- 'docs/**'
10+
- '**/*.md'
11+
- '.context/**'
12+
- '.rules/**'
13+
- '.serena/**'
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
auto-dev-bump:
20+
name: Auto Bump Dev Version
21+
runs-on: ubuntu-latest
22+
# Skip if commit message already contains a version bump (avoid loops)
23+
if: >-
24+
!contains(github.event.head_commit.message, 'Bump version to')
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v6
29+
with:
30+
fetch-depth: 0
31+
token: ${{ secrets.RELEASE_PAT }}
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v6
35+
with:
36+
python-version: '3.12'
37+
38+
- name: Configure Git
39+
run: |
40+
git config user.name "github-actions[bot]"
41+
git config user.email "github-actions[bot]@users.noreply.github.com"
42+
43+
- name: Get current version
44+
id: current
45+
run: |
46+
VERSION=$(grep -m1 'version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
47+
echo "version=$VERSION" >> $GITHUB_OUTPUT
48+
echo "Current version: $VERSION"
49+
50+
- name: Calculate new dev version
51+
id: new_version
52+
run: |
53+
VERSION="${{ steps.current.outputs.version }}"
54+
55+
# Parse version: expects format like 0.7.5.dev0 or 0.7.5
56+
if [[ "$VERSION" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(\.dev([0-9]+))?$ ]]; then
57+
BASE="${BASH_REMATCH[1]}"
58+
DEV_NUM="${BASH_REMATCH[3]}"
59+
60+
if [ -z "$DEV_NUM" ]; then
61+
# No dev suffix yet, start at dev0
62+
NEW_VERSION="${BASE}.dev0"
63+
else
64+
# Increment dev number
65+
NEW_DEV=$((DEV_NUM + 1))
66+
NEW_VERSION="${BASE}.dev${NEW_DEV}"
67+
fi
68+
else
69+
echo "Unexpected version format for develop: $VERSION (expected X.Y.Z or X.Y.Z.devN)"
70+
exit 1
71+
fi
72+
73+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
74+
echo "New version: $NEW_VERSION"
75+
76+
- name: Update version files
77+
run: |
78+
NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
79+
80+
# Parse version for __version_info__
81+
MAJOR=$(echo "$NEW_VERSION" | cut -d. -f1)
82+
MINOR=$(echo "$NEW_VERSION" | cut -d. -f2)
83+
PATCH=$(echo "$NEW_VERSION" | cut -d. -f3)
84+
85+
# Update pyproject.toml
86+
sed -i "s/^version = .*/version = \"$NEW_VERSION\"/" pyproject.toml
87+
88+
# Update src/version.py
89+
cat > src/version.py << PYEOF
90+
"""Version information for HEDit."""
91+
92+
__version__ = "$NEW_VERSION"
93+
__version_info__ = ($MAJOR, $MINOR, $PATCH, "dev")
94+
95+
96+
def get_version() -> str:
97+
"""Get the current version string."""
98+
return __version__
99+
100+
101+
def get_version_info() -> tuple:
102+
"""Get the version info tuple (major, minor, patch, prerelease)."""
103+
return __version_info__
104+
PYEOF
105+
# Fix indentation (remove leading spaces from heredoc)
106+
sed -i 's/^ //' src/version.py
107+
108+
- name: Commit version bump
109+
run: |
110+
NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
111+
git add pyproject.toml src/version.py
112+
git commit -m "Bump version to $NEW_VERSION"
113+
git push origin develop
114+
115+
- name: Create and push tag
116+
run: |
117+
NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
118+
git tag "v$NEW_VERSION"
119+
git push origin "v$NEW_VERSION"
120+
echo "Created tag: v$NEW_VERSION"

0 commit comments

Comments
 (0)