Skip to content

Commit e32d51c

Browse files
authored
Merge pull request #32 from ajbozarth/post_release_ci
chore: add post release ci to update version
2 parents af1b193 + e63d7df commit e32d51c

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Post Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
followup-pr:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
- name: run bump_version.py
21+
run: |
22+
python tools/bump_version.py
23+
env:
24+
GITHUB_REF_NAME: ${{ github.ref_name }}
25+
- name: Create pull request
26+
uses: peter-evans/create-pull-request@v6
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
commit-message: "chore: follow-up after release ${{ github.ref_name }}"
30+
branch: followup-${{ github.ref_name }}-${{ github.run_id }}
31+
base: main
32+
title: "chore: follow-up after release ${{ github.ref_name }}"
33+
body: |
34+
This PR was automatically created after tagging `${{ github.ref_name }}` to:
35+
- Bump `pyproject.toml` to next development version

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "maestro-knowledge"
3-
version = "0.6.0"
3+
version = "0.7.0"
44
description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.11"

tools/bump_version.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import re
5+
from pathlib import Path
6+
7+
8+
def parse_version(tag: str) -> tuple[int, ...]:
9+
version_str = tag.lstrip("v")
10+
return tuple(map(int, version_str.strip().split(".")))
11+
12+
13+
def main():
14+
github_tag = os.environ.get("GITHUB_REF_NAME")
15+
if not github_tag:
16+
print("::error::GITHUB_REF_NAME not set.")
17+
exit(1)
18+
if not re.fullmatch(r"v\d+\.\d+\.\d+", github_tag):
19+
print(
20+
f"::error::Invalid GITHUB_REF_NAME '{github_tag}'. Expected format: vX.Y.Z"
21+
)
22+
exit(1)
23+
24+
major, minor, patch = parse_version(github_tag)
25+
next_version_str = f"{major}.{minor + 1}.0"
26+
27+
print(f"Bumping pyproject.toml to {next_version_str}")
28+
29+
repo_root = Path(__file__).resolve().parent.parent
30+
pyproject_path = repo_root / "pyproject.toml"
31+
32+
pyproject_content = pyproject_path.read_text()
33+
updated_pyproject = re.sub(
34+
r'version\s*=\s*"\d+\.\d+\.\d+"',
35+
f'version = "{next_version_str}"',
36+
pyproject_content,
37+
)
38+
pyproject_path.write_text(updated_pyproject)
39+
print(f"✔️ Bumped pyproject.toml version to {next_version_str}")
40+
41+
42+
if __name__ == "__main__":
43+
main()

0 commit comments

Comments
 (0)