File: create-release

package info (click to toggle)
intrusive-shared-ptr 1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 412 kB
  • sloc: cpp: 2,852; ansic: 173; makefile: 3
file content (39 lines) | stat: -rwxr-xr-x 1,300 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/env -S python3 -u

# pylint: disable=missing-module-docstring, missing-function-docstring, line-too-long

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", encoding='utf-8') 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/intrusive_shared_ptr/releases/v{NEW_VER}\n')

with open(ROOT / "CHANGELOG.md", "wt", encoding='utf-8') 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'v{NEW_VER}'], check=True)