Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/post-release-mergeback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ jobs:
- name: Prepare partial Changelog
env:
PARTIAL_CHANGELOG: "${{ runner.temp }}/partial_changelog.md"
VERSION: "${{ steps.getVersion.outputs.version }}"
run: |
python .github/workflows/script/prepare_changelog.py CHANGELOG.md "$VERSION" > $PARTIAL_CHANGELOG
python .github/workflows/script/prepare_changelog.py CHANGELOG.md > $PARTIAL_CHANGELOG

echo "::group::Partial CHANGELOG"
cat $PARTIAL_CHANGELOG
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/rollback-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ jobs:
env:
NEW_CHANGELOG: "${{ runner.temp }}/new_changelog.md"
PARTIAL_CHANGELOG: "${{ runner.temp }}/partial_changelog.md"
VERSION: "${{ needs.prepare.outputs.version }}"
run: |
python .github/workflows/script/prepare_changelog.py $NEW_CHANGELOG "$VERSION" > $PARTIAL_CHANGELOG
python .github/workflows/script/prepare_changelog.py $NEW_CHANGELOG > $PARTIAL_CHANGELOG

echo "::group::Partial CHANGELOG"
cat $PARTIAL_CHANGELOG
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/script/bundle_changelog.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/usr/bin/env python3
import os
import re

cli_version = os.environ['CLI_VERSION']

# Link the GitHub Release corresponding to the new bundle version.
bundle_release_url = f"https://github.com/github/codeql-action/releases/tag/codeql-bundle-v{cli_version}"
bundle_note = f"To learn more about the relevant changes to the CodeQL CLI and language packs, see the [bundle release]({bundle_release_url})."

# Get the PR number from the PR URL.
pr_number = os.environ['PR_URL'].split('/')[-1]
changelog_note = f"- Update default CodeQL bundle version to {os.environ['CLI_VERSION']}. [#{pr_number}]({os.environ['PR_URL']})"
changelog_note = f"- Update default CodeQL bundle version to {cli_version}. {bundle_note} [#{pr_number}]({os.environ['PR_URL']})"

# If the "[UNRELEASED]" section starts with "no user facing changes", remove that line.
with open('CHANGELOG.md', 'r') as f:
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/script/prepare_changelog.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
import os
import sys

Expand All @@ -6,7 +7,7 @@
# 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):
def extract_changelog_snippet(changelog_file):
output = ''
if (not os.path.exists(changelog_file)):
output = EMPTY_CHANGELOG
Expand All @@ -15,23 +16,20 @@ def extract_changelog_snippet(changelog_file, version_tag):
with open(changelog_file, 'r') as f:
lines = f.readlines()

# Include everything up to, but excluding the second heading
# Include only the contents of the first section
found_first_section = False
for i, line in enumerate(lines):
for line in lines:
if line.startswith('## '):
if found_first_section:
break
found_first_section = True
output += line
elif found_first_section:
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.strip()

return output


if len(sys.argv) < 3:
raise Exception('Expecting argument: changelog_file version_tag')
if len(sys.argv) < 2:
raise Exception('Expecting argument: changelog_file')
changelog_file = sys.argv[1]
version_tag = sys.argv[2]

print(extract_changelog_snippet(changelog_file, version_tag))
print(extract_changelog_snippet(changelog_file))
Loading