Skip to content

Commit 058be5f

Browse files
authored
Merge pull request #4 from geopanther/ci/bumpversion-rc-support
chore: simplify bumpversion config and bump to 0.2.1-rc1
2 parents 5688ea5 + 596b24c commit 058be5f

5 files changed

Lines changed: 46 additions & 7 deletions

File tree

.bumpversion.cfg

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
[bumpversion]
22
commit = False
33
tag = False
4-
current_version = 0.2.0
4+
current_version = 0.2.1-rc1
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
6-
serialize =
6+
serialize =
77
{major}.{minor}.{patch}-{release}{build}
88
{major}.{minor}.{patch}
99

1010
[bumpversion:part:release]
1111
optional_value = _
1212
first_value = _
13-
values =
13+
values =
1414
_
15-
a
16-
b
15+
rc
1716
_
1817

1918
[bumpversion:part:build]

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ repos:
2626
- id: flake8
2727
- repo: local
2828
hooks:
29+
- id: revert-changelog-rc
30+
name: revert-changelog-rc
31+
entry: python scripts/revert_changelog_rc.py
32+
language: python
33+
files: CHANGELOG.md
34+
stages: [pre-commit]
2935
- id: tox
3036
name: tox
3137
entry: tox -e py312

mdfluence/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.2.0"
1+
__version__ = "0.2.1-rc1"
22
__url__ = "https://github.com/geopanther/mdfluence"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "mdfluence"
7-
version = "0.2.0"
7+
version = "0.2.1-rc1"
88
description = "Convert and upload Markdown documents to Confluence (fork of md2cf by Jack Gaino)"
99
readme = "README.md"
1010
license = "MIT"

scripts/revert_changelog_rc.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
"""Pre-commit hook: revert rc version headings in CHANGELOG.md back to Unreleased.
3+
4+
If bump2version writes a heading like '## 0.2.1-rc1 - 2026-04-15',
5+
this hook reverts it to '## Unreleased' so that only final releases
6+
get permanent version headings in the changelog.
7+
"""
8+
9+
import re
10+
import sys
11+
from pathlib import Path
12+
13+
CHANGELOG = Path("CHANGELOG.md")
14+
RC_HEADING = re.compile(r"^## \d+\.\d+\.\d+-rc\d+ - \d{4}-\d{2}-\d{2}$", re.MULTILINE)
15+
16+
17+
def main() -> int:
18+
if not CHANGELOG.exists():
19+
return 0
20+
21+
text = CHANGELOG.read_text()
22+
new_text, count = RC_HEADING.subn("## Unreleased", text)
23+
24+
if count > 0:
25+
CHANGELOG.write_text(new_text)
26+
# Re-stage the file so the commit includes the reverted heading
27+
print(f"Reverted {count} rc heading(s) in CHANGELOG.md back to Unreleased")
28+
return 1 # Signal pre-commit to re-stage and retry
29+
30+
return 0
31+
32+
33+
if __name__ == "__main__":
34+
sys.exit(main())

0 commit comments

Comments
 (0)