Extract version changelog in release process
Release / release (push) Failing after 4s

This commit is contained in:
2026-08-30 13:45:40 +01:00
parent a1123b361d
commit 08029141d4
2 changed files with 73 additions and 1 deletions
+16 -1
View File
@@ -34,6 +34,20 @@ jobs:
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Extract version changelog
id: changelog
run: |
# VERSION="${{ steps.tag.outputs.version }}"
VERSION=$(cat VERSION | tr -d '[:space:]') # read version and trim whitespace
CHANGELOG_FILE=$(python scripts/get_changelog.py $VERSION)
if [[ $? != 0 ]]; then
echo "No changelog found for version $VERSION"
exit 1
fi
echo "changelog=$(cat $CHANGELOG_FILE)" >> $GITHUB_OUTPUT
- name: Build Artifacts
if: steps.tag.outputs.version
run: |
@@ -46,6 +60,7 @@ jobs:
id: create_release
run: |
VERSION="${{ steps.tag.outputs.version }}"
CHANGELOG="${{ steps.changelog.outputs.changelog }}"
RESPONSE=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
@@ -53,7 +68,7 @@ jobs:
-d '{
"tag_name": "v'"$VERSION"'",
"name": "wapp-v'"$VERSION"'",
"body": "Automated release for wapp-v'"$VERSION"'",
"body": "'"$CHANGELOG"'",
"draft": false,
"prerelease": false
}')
+57
View File
@@ -0,0 +1,57 @@
import os
import re
import argparse
from pathlib import Path
from tempfile import mkstemp
VERSION_HEADER = re.compile(r"\[\d+.\d+.\d+\]")
def main():
parser = argparse.ArgumentParser()
parser.add_argument("version")
args = parser.parse_args()
changelog = get_changelog(args.version)
outfilename = save_changelog(args.version, changelog)
print(outfilename)
def get_changelog(version: str) -> list[str]:
script_dir = Path(__file__).absolute().parent.parent
changelog = script_dir / "CHANGELOG.md"
with changelog.open("r") as infile:
lines = infile.readlines()
start = -1
end = -1
for i, line in enumerate(lines):
if start == -1:
match = re.search(version, line)
if match is None:
continue
start = i
else:
match = VERSION_HEADER.search(line)
if match is not None:
end = i
break
if start == -1:
exit(1)
return lines[start:end] if end > -1 else lines[start:]
def save_changelog(version: str, lines: list[str]) -> str:
fd, name = mkstemp(prefix=f"wapp-changelog-{version}-", text=True)
os.write(fd, "".join(lines).encode("utf-8"))
os.close(fd)
return name
if __name__ == "__main__":
main()