Add a partial changelog when releasing
This commit is contained in:
parent
9b4db1efbf
commit
d545e9b4a6
2 changed files with 51 additions and 3 deletions
17
.github/workflows/post-release-mergeback.yml
vendored
17
.github/workflows/post-release-mergeback.yml
vendored
|
|
@ -151,13 +151,24 @@ jobs:
|
|||
--assignee "${GITHUB_ACTOR}" \
|
||||
--draft
|
||||
|
||||
|
||||
- name: Prepare the partial Changelog
|
||||
env:
|
||||
VERSION: "${{ steps.getVersion.outputs.version }}"
|
||||
PARTIAL_CHANGELOG: "${{ runner.temp }}/partial_changelog.md"
|
||||
run: |
|
||||
# Prepare the partial changelog for the release notes
|
||||
python .github/workflows/script/prepare_changelog.py CHANGELOG.md "$VERSION"> $PARTIAL_CHANGELOG
|
||||
|
||||
- name: Create the GitHub release
|
||||
env:
|
||||
VERSION: "${{ steps.getVersion.outputs.version }}"
|
||||
PARTIAL_CHANGELOG: "${{ runner.temp }}/partial_changelog.md"
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Do not mark this release as latest. The most recent CLI release must be marked as latest.
|
||||
gh release create \
|
||||
"${VERSION}" \
|
||||
"$VERSION" \
|
||||
--latest=false \
|
||||
-t "${VERSION}" \
|
||||
-F CHANGELOG.md
|
||||
-t "$VERSION" \
|
||||
-F "$PARTIAL_CHANGELOG"
|
||||
|
|
|
|||
37
.github/workflows/script/prepare_changelog.py
vendored
Normal file
37
.github/workflows/script/prepare_changelog.py
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
EMPTY_CHANGELOG = 'No changes.\n\n'
|
||||
|
||||
# Prepare the changelog for the new release
|
||||
# This function will extract the part of the changelog that
|
||||
# we want to include in the new release.
|
||||
def extract_changelog_snippet(changelog_file, version_tag):
|
||||
output = ''
|
||||
if (not os.path.exists(changelog_file)):
|
||||
output = EMPTY_CHANGELOG
|
||||
|
||||
else:
|
||||
with open('CHANGELOG.md', 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# Include everything up to, but excluding the second heading
|
||||
found_first_section = False
|
||||
for i, line in enumerate(lines):
|
||||
if line.startswith('## '):
|
||||
if found_first_section:
|
||||
break
|
||||
found_first_section = True
|
||||
output += line
|
||||
|
||||
output += f"See the full [CHANGELOG.md](https://github.com/github/codeql-action/blob/{version_tag}/CHANGELOG.md) for more information."
|
||||
|
||||
return output
|
||||
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
raise Exception('Expecting argument: changelog_file version_tag')
|
||||
changelog_file = sys.argv[1]
|
||||
version_tag = sys.argv[2]
|
||||
|
||||
print(extract_changelog_snippet(changelog_file, version_tag))
|
||||
Loading…
Add table
Add a link
Reference in a new issue