Skip to content

Commit

Permalink
Adding release creation tool
Browse files Browse the repository at this point in the history
  • Loading branch information
gershnik committed May 7, 2024
1 parent a1c54ad commit 66b0a86
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .tools/create-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /usr/bin/env -S python3 -u

import sys
import re
import subprocess

from pathlib import Path
from datetime import date

MYPATH = Path(__file__).parent
ROOT = MYPATH.parent

NEW_VER = sys.argv[1]

unreleased_link_pattern = re.compile(r"^\[Unreleased\]: (.*)$", re.DOTALL)
lines = []
with open(ROOT / "CHANGELOG.md", "rt") as change_log:
for line in change_log.readlines():
# Move Unreleased section to new version
if re.fullmatch(r"^## Unreleased.*$", line, re.DOTALL):
lines.append(line)
lines.append("\n")
lines.append(
f"## [{NEW_VER}] - {date.today().isoformat()}\n"
)
else:
lines.append(line)
lines.append(f'[{NEW_VER}]: https://github.com/gershnik/SimpleJNI/releases/{NEW_VER}\n')

with open(ROOT / "CHANGELOG.md", "wt") as change_log:
change_log.writelines(lines)

(ROOT / "VERSION").write_text(f'{NEW_VER}\n')

subprocess.run(['git', 'add', ROOT / "CHANGELOG.md", ROOT / "VERSION"], check=True)
subprocess.run(['git', 'commit', '-m', f'chore: creating version {NEW_VER}'], check=True)
subprocess.run(['git', 'tag', f'{NEW_VER}'], check=True)

0 comments on commit 66b0a86

Please sign in to comment.