Files
chatmail-core/scripts/release.py
Hocuri f30a1a3865 chore: Add git-cliff as a changelog generation tool
Changelogs will be generated using commit messages by
`scripts/release.py`.

Both the commit message and the PR title should follow https://conventionalcommits.org. E.g. start with 'feat:' (for Features / Changes), 'fix:' (for Fixes), 'api:' (for API-Changes), 'api!:' for breaking API-Changes) 'refactor:' (for Refactor), 'perf:' (for Performance), 'test:' (for Tests), 'style:' (for Styling), 'chore:' (for Miscellaneous Tasks)
2023-05-06 15:20:58 +02:00

40 lines
1.0 KiB
Python

#!/usr/bin/env python3
import sys
import subprocess
import set_core_version
from argparse import ArgumentParser
# update the version
parser = ArgumentParser(prog="release")
parser.add_argument("newversion")
try:
newversion = parser.parse_args().newversion
except SystemExit:
newversion = None
set_core_version.set_version(newversion)
tag = "v" + newversion
# TODO would be nice to automatically checkout the correct branch
# update the changelog
print(f"Updating CHANGELOG.md using git cliff --unreleased --tag {newversion} --prepend CHANGELOG.md")
changelog = subprocess.run(["git", "cliff", "--unreleased", "--tag", newversion, "--prepend", "CHANGELOG.md"]).stdout.strip()
subprocess.run(["git", "add", "-A"])
subprocess.run(["git", "commit", "-m", f"chore(release): prepare for {tag}"])
subprocess.run(["git", "show"])
# create a tag
subprocess.run(
[
"git", "tag", "-a", tag, "-m", f"Release {tag}", "-m", changelog
]
)
subprocess.run(["git", "tag", "-v", tag])
print("Done!")
print(f"Now push the commit (git push origin {tag}).")