Skip to content

Commit 494f65f

Browse files
Merge pull request #8 from akshatnerella/akshatnerella/ci-pipeline-updates
bump version logic changes
2 parents e3525a5 + 67423a5 commit 494f65f

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

.github/scripts/pr_bump_version.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,8 @@ def parse_setup_version(text: str) -> str:
2424
return match.group(1)
2525

2626

27-
def latest_tag_version() -> str | None:
28-
tags = run("git", "tag", "--list", "v*", "--sort=-v:refname").splitlines()
29-
for tag in tags:
30-
if re.fullmatch(r"v\d+\.\d+\.\d+", tag):
31-
return tag[1:]
32-
return None
33-
34-
35-
def base_branch_version(base_ref: str) -> str:
36-
setup_on_base = run("git", "show", f"origin/{base_ref}:setup.py")
27+
def base_branch_version(base_remote: str, base_ref: str) -> str:
28+
setup_on_base = run("git", "show", f"{base_remote}/{base_ref}:setup.py")
3729
return parse_setup_version(setup_on_base)
3830

3931

@@ -67,11 +59,12 @@ def main() -> None:
6759
parser = argparse.ArgumentParser()
6860
parser.add_argument("--bump", choices=["major", "minor", "patch"], required=True)
6961
parser.add_argument("--base-ref", required=True)
62+
parser.add_argument("--base-remote", default="origin")
7063
args = parser.parse_args()
7164

7265
setup_text = Path("setup.py").read_text(encoding="utf-8")
7366
current_version = parse_setup_version(setup_text)
74-
base_version = latest_tag_version() or base_branch_version(args.base_ref)
67+
base_version = base_branch_version(args.base_remote, args.base_ref)
7568
target_version = bump_version(base_version, args.bump)
7669

7770
changed = update_setup(target_version)

.github/workflows/pr-version-bump.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ jobs:
6868
repository: ${{ github.event.pull_request.head.repo.full_name }}
6969
fetch-depth: 0
7070

71-
- name: Fetch base branch and tags
71+
- name: Fetch base branch
7272
run: |
7373
git fetch origin "${{ github.event.pull_request.base.ref }}"
74-
git fetch --tags
7574
7675
- name: Bump setup.py version
7776
id: bump
7877
run: |
7978
python .github/scripts/pr_bump_version.py \
8079
--bump "${{ steps.label.outputs.bump }}" \
81-
--base-ref "${{ github.event.pull_request.base.ref }}"
80+
--base-ref "${{ github.event.pull_request.base.ref }}" \
81+
--base-remote "origin"
8282
8383
- name: Commit and push version update
8484
if: steps.bump.outputs.changed == 'true'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ One-time setup required:
117117
- `release:minor`
118118
- `release:patch`
119119
4. If no release label is present, the workflow automatically adds `release:patch` and bumps patch version.
120+
5. Automatic version bump commits run for same-repository PR branches; fork PRs require a maintainer to apply/version-bump after merge.
120121

121122
If the version already exists on PyPI, publish is skipped safely.
122123

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='pyladdersim',
5-
version='0.1.1',
5+
version='0.1.2',
66
packages=find_packages(exclude=["tests", "tests.*"]),
77
install_requires=[
88
'matplotlib',

0 commit comments

Comments
 (0)