Update Github release from changelog

This commit is contained in:
Philipp Wolfer
2019-11-26 15:27:56 +01:00
parent 2cc0b35cfe
commit d8d612e29f
2 changed files with 50 additions and 0 deletions

29
.github/workflows/github-release.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: Prepare release
on:
push:
tags:
- 'release-*'
jobs:
prepare-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Prepare changelog
id: changelog
run: |
PICARD_VERSION=$(python -c "import picard; print(picard.__version__)")
echo "::set-output name=version::"$PICARD_VERSION
./scripts/package/changelog-for-version.py $PICARD_VERSION > changes-$PICARD_VERSION.txt
- name: Update release
uses: softprops/action-gh-release@v1
with:
name: MusicBrainz Picard ${{ steps.changelog.outputs.version }}
body_path: changes-${{ steps.changelog.outputs.version }}.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python
import re
import sys
if len(sys.argv) == 1:
print("Call with changelog-for-version.py [version]", file=sys.stderr)
sys.exit(1)
version = sys.argv[1]
re_changes = re.compile(r'^# Version ' + re.escape(version) + '.*?\n(.*?)# Version',
re.DOTALL | re.MULTILINE)
with open('NEWS.md', 'r') as newsfile:
news = newsfile.read()
result = re_changes.search(news)
if not result:
print("No changelog found for version %s" % version, file=sys.stderr)
sys.exit(1)
print(result[1].strip())