Add automatic release information
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Marty Oehme 2023-01-13 20:09:59 +01:00
parent 76737b3467
commit dcf367b385
Signed by: Marty
GPG Key ID: 73BA40D5AFAF49C9
2 changed files with 67 additions and 1 deletions

View File

@ -20,7 +20,17 @@ pipeline:
- python --version && poetry --version
- poetry build
when:
branch: main
event: tag
tag: v*
release_prep:
image: python
commands:
- echo "----------------- preparing release ------------------"
- python tools/extract-changelog.py
when:
event: tag
tag: v*
gitea_release:
image: plugins/gitea-release

View File

@ -0,0 +1,56 @@
import re
## Extracts the version and newest changes from a semantic changelog.
#
# Important, it only works with three-parted version numbers
# a-la 1.2.3 or 313.01.1888 -- needs \d.\d.\d to work.
#
# The version number and changeset will be put in `NEWEST_VERSION.md`
# and `NEWEST_CHANGES.md` respectively, for further use in releases.
OUTPUT_FILE_VERSION = "NEWEST_VERSION.md"
OUTPUT_FILE_CHANGES = "NEWEST_CHANGES.md"
def getVersion(file):
for line in file:
m = re.match(r"^## \[(\d+\.\d+\.\d+)\]", line)
if m and m.group(1):
return m.group(1)
def getSection(file):
inRecordingMode = False
for line in file:
if not inRecordingMode:
if re.match(r"^## \[\d+\.\d+\.\d+\]", line):
inRecordingMode = True
elif re.match(r"^## \[\d+\.\d+\.\d+\]", line):
inRecordingMode = False
break
elif re.match(r"^$", line):
pass
else:
yield line
def toFile(fname, content):
file = open(fname, "w")
file.write(content)
file.close()
with open("CHANGELOG.md") as file:
title = getVersion(file)
print(title)
toFile(OUTPUT_FILE_VERSION, title)
with open("CHANGELOG.md") as file:
newest_changes_gen = getSection(file)
newest_changes = ""
for line in newest_changes_gen:
newest_changes += line
print("[Extracted Changelog]")
print(newest_changes)
toFile(OUTPUT_FILE_CHANGES, newest_changes)
file.close()