Skip to content

Commit 01480a7

Browse files
committed
Add changelog and release scripts.
1 parent 510e496 commit 01480a7

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 1.0 (2020-03-08)
2+
3+
* First official release.

dev/make-release-notes.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#! /usr/bin/env python3
2+
3+
import re
4+
import sys
5+
6+
_, VERSION, CHANGELOG, LIST = sys.argv
7+
HEADER_REGEX = fr"# {VERSION} \(\d\d\d\d-\d\d-\d\d\)\n"
8+
9+
notes_list = []
10+
11+
12+
def add_to_release_notes(line):
13+
assert line.endswith("."), line
14+
notes_list.append(f"* {line}\n")
15+
16+
17+
with open(CHANGELOG) as f:
18+
first_line = next(f)
19+
if not re.match(HEADER_REGEX, first_line):
20+
sys.exit(
21+
f'First changelog line "{first_line.rstrip()}" must '
22+
f'start with "{HEADER_REGEX.rstrip()}"'
23+
)
24+
notes_list.extend([first_line[2:], "\n"])
25+
for line in f:
26+
if not line.strip():
27+
continue
28+
if line.startswith("* "):
29+
add_to_release_notes(line[2:].strip())
30+
else:
31+
break
32+
33+
34+
def check(name, text):
35+
print("*" * 60)
36+
print(text)
37+
print("*" * 60)
38+
response = input("Accept this %s (Y/n)? " % name).strip().lower()
39+
if response and response != "y":
40+
sys.exit(1)
41+
42+
43+
check("changelog", "".join(notes_list))
44+
45+
with open(LIST, "w") as f:
46+
f.writelines(notes_list)

dev/release.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#! /bin/bash
2+
3+
set -exuo pipefail
4+
5+
VERSION="$1"
6+
CHANGES="/tmp/pyperplan-$VERSION-changes"
7+
8+
cd $(dirname "$0")/../
9+
10+
# Check for uncommited changes.
11+
set +e
12+
git diff --quiet && git diff --cached --quiet
13+
retcode=$?
14+
set -e
15+
if [[ $retcode != 0 ]]; then
16+
echo "There are uncommited changes:"
17+
git status
18+
exit 1
19+
fi
20+
21+
if [[ $(git rev-parse --abbrev-ref HEAD) != master ]]; then
22+
echo "Must be on master for release"
23+
exit 1
24+
fi
25+
26+
git tag -a "v$VERSION" -m "v$VERSION" HEAD
27+
28+
git push
29+
git push --tags
30+
31+
# Add changelog to Github release.
32+
./dev/make-release-notes.py "$VERSION" CHANGELOG.md "$CHANGES"
33+
hub release create "v$VERSION" --file "$CHANGES"

0 commit comments

Comments
 (0)