diff --git a/.github/workflows/post-release-mergeback.yml b/.github/workflows/post-release-mergeback.yml index 71091e6d44..95e66ecd79 100644 --- a/.github/workflows/post-release-mergeback.yml +++ b/.github/workflows/post-release-mergeback.yml @@ -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 diff --git a/.github/workflows/rollback-release.yml b/.github/workflows/rollback-release.yml index 5c3b7efdd1..4b5b68cf36 100644 --- a/.github/workflows/rollback-release.yml +++ b/.github/workflows/rollback-release.yml @@ -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 diff --git a/.github/workflows/script/bundle_changelog.py b/.github/workflows/script/bundle_changelog.py old mode 100644 new mode 100755 index 8a7135f1e4..42a9589a8b --- a/.github/workflows/script/bundle_changelog.py +++ b/.github/workflows/script/bundle_changelog.py @@ -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: diff --git a/.github/workflows/script/prepare_changelog.py b/.github/workflows/script/prepare_changelog.py old mode 100644 new mode 100755 index 24a062ce05..dafb84b39c --- a/.github/workflows/script/prepare_changelog.py +++ b/.github/workflows/script/prepare_changelog.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import os import sys @@ -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 @@ -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))