Skip to content

Commit 012739e

Browse files
authored
Merge pull request #2052 from github/update-v3.22.12-40cb08c12
Merge main into releases/v3
2 parents b374143 + c1cf794 commit 012739e

File tree

71 files changed

+1820
-1232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1820
-1232
lines changed

.github/actions/release-branches/release-branches.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import argparse
22
import json
33
import os
4-
import subprocess
4+
import configparser
55

66
# Name of the remote
77
ORIGIN = 'origin'
88

9-
OLDEST_SUPPORTED_MAJOR_VERSION = 2
9+
script_dir = os.path.dirname(os.path.realpath(__file__))
10+
grandparent_dir = os.path.dirname(os.path.dirname(script_dir))
11+
12+
config = configparser.ConfigParser()
13+
with open(os.path.join(grandparent_dir, 'releases.ini')) as stream:
14+
config.read_string('[default]\n' + stream.read())
15+
16+
OLDEST_SUPPORTED_MAJOR_VERSION = int(config['default']['OLDEST_SUPPORTED_MAJOR_VERSION'])
1017

1118
def main():
1219

.github/releases.ini

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OLDEST_SUPPORTED_MAJOR_VERSION=2

.github/update-release-branch.py

+56-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import argparse
22
import datetime
3+
import re
34
from github import Github
45
import json
56
import os
@@ -174,6 +175,60 @@ def get_today_string():
174175
today = datetime.datetime.today()
175176
return '{:%d %b %Y}'.format(today)
176177

178+
def process_changelog_for_backports(source_branch_major_version, target_branch_major_version):
179+
180+
# changelog entries can use the following format to indicate
181+
# that they only apply to newer versions
182+
some_versions_only_regex = re.compile(r'\[v(\d+)\+ only\]')
183+
184+
output = ''
185+
186+
with open('CHANGELOG.md', 'r') as f:
187+
188+
# until we find the first section, just duplicate all lines
189+
while True:
190+
line = f.readline()
191+
if not line:
192+
raise Exception('Could not find any change sections in CHANGELOG.md') # EOF
193+
194+
output += line
195+
if line.startswith('## '):
196+
line = line.replace(f'## {source_branch_major_version}', f'## {target_branch_major_version}')
197+
# we have found the first section, so now handle things differently
198+
break
199+
200+
# found_content tracks whether we hit two headings in a row
201+
found_content = False
202+
output += '\n'
203+
while True:
204+
line = f.readline()
205+
if not line:
206+
break # EOF
207+
line = line.rstrip('\n')
208+
209+
# filter out changenote entries that apply only to newer versions
210+
match = some_versions_only_regex.search(line)
211+
if match:
212+
if int(target_branch_major_version) < int(match.group(1)):
213+
continue
214+
215+
if line.startswith('## '):
216+
line = line.replace(f'## {source_branch_major_version}', f'## {target_branch_major_version}')
217+
if found_content == False:
218+
# we have found two headings in a row, so we need to add the placeholder message.
219+
output += 'No user facing changes.\n'
220+
found_content = False
221+
output += f'\n{line}\n\n'
222+
else:
223+
if line.strip() != '':
224+
found_content = True
225+
# we use the original line here, rather than the stripped version
226+
# so that we preserve indentation
227+
output += line + '\n'
228+
229+
with open('CHANGELOG.md', 'w') as f:
230+
f.write(output)
231+
177232
def update_changelog(version):
178233
if (os.path.exists('CHANGELOG.md')):
179234
content = ''
@@ -324,13 +379,7 @@ def main():
324379

325380
# Migrate the changelog notes from vLatest version numbers to vOlder version numbers
326381
print(f'Migrating changelog notes from v{source_branch_major_version} to v{target_branch_major_version}')
327-
subprocess.check_output(['sed', '-i', f's/^## {source_branch_major_version}\./## {target_branch_major_version}./g', 'CHANGELOG.md'])
328-
329-
# Remove changelog notes from all versions that do not apply to the vOlder branch
330-
print(f'Removing changelog notes that do not apply to v{target_branch_major_version}')
331-
for v in range(int(source_branch_major_version), int(target_branch_major_version), -1):
332-
print(f'Removing changelog notes that are tagged [v{v}+ only\]')
333-
subprocess.check_output(['sed', '-i', f'/^- \[v{v}+ only\]/d', 'CHANGELOG.md'])
382+
process_changelog_for_backports(source_branch_major_version, target_branch_major_version)
334383

335384
# Amend the commit generated by `npm version` to update the CHANGELOG
336385
run_git('add', 'CHANGELOG.md')

.github/workflows/post-release-mergeback.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ jobs:
133133
# Update the version number ready for the next release
134134
npm version patch --no-git-tag-version
135135
136-
# Update the changelog
137-
perl -i -pe 's/^/## \[UNRELEASED\]\n\nNo user facing changes.\n\n/ if($.==5)' CHANGELOG.md
136+
# Update the changelog, adding a new version heading directly above the most recent existing one
137+
awk '!f && /##/{print "'"## [UNRELEASED]\n\nNo user facing changes.\n"'"; f=1}1' CHANGELOG.md > temp && mv temp CHANGELOG.md
138138
git add .
139139
git commit -m "Update changelog and version after ${VERSION}"
140140

.github/workflows/script/update-required-checks.sh

+21-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
# Update the required checks based on the current branch.
33
# Typically, this will be main.
44

5+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
REPO_DIR="$(dirname "$SCRIPT_DIR")"
7+
GRANDPARENT_DIR="$(dirname "$REPO_DIR")"
8+
source "$GRANDPARENT_DIR/releases.ini"
9+
510
if ! gh auth status 2>/dev/null; then
611
gh auth status
712
echo "Failed: Not authorized. This script requires admin access to github/codeql-action through the gh CLI."
@@ -29,7 +34,22 @@ echo "$CHECKS" | jq
2934

3035
echo "{\"contexts\": ${CHECKS}}" > checks.json
3136

32-
for BRANCH in main releases/v2; do
37+
echo "Updating main"
38+
gh api --silent -X "PATCH" "repos/github/codeql-action/branches/main/protection/required_status_checks" --input checks.json
39+
40+
# list all branchs on origin remote matching releases/v*
41+
BRANCHES="$(git ls-remote --heads origin 'releases/v*' | sed 's?.*refs/heads/??' | sort -V)"
42+
43+
for BRANCH in $BRANCHES; do
44+
45+
# strip exact 'releases/v' prefix from $BRANCH using count of characters
46+
VERSION="${BRANCH:10}"
47+
48+
if [ "$VERSION" -lt "$OLDEST_SUPPORTED_MAJOR_VERSION" ]; then
49+
echo "Skipping $BRANCH"
50+
continue
51+
fi
52+
3353
echo "Updating $BRANCH"
3454
gh api --silent -X "PATCH" "repos/github/codeql-action/branches/$BRANCH/protection/required_status_checks" --input checks.json
3555
done

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
44

5+
Note that the only difference between `v2` and `v3` of the CodeQL Action is the node version they support, with `v3` running on node 20 while we continue to release `v2` to support running on node 16. For example `3.22.11` was the first `v3` release and is functionally identical to `2.22.11`. This approach ensures an easy way to track exactly which features are included in different versions, indicated by the minor and patch version numbers.
6+
7+
## 3.22.12 - 22 Dec 2023
8+
9+
- Update default CodeQL bundle version to 2.15.5. [#2047](https://github.com/github/codeql-action/pull/2047)
10+
511
## 3.22.11 - 13 Dec 2023
612

713
- [v3+ only] The CodeQL Action now runs on Node.js v20. [#2006](https://github.com/github/codeql-action/pull/2006)

CONTRIBUTING.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ Since the `codeql-action` runs most of its testing through individual Actions wo
7676

7777
1. By default, this script retrieves the checks from the latest SHA on `main`, so make sure that your `main` branch is up to date.
7878
2. Run the script. If there's a reason to, you can pass in a different SHA as a CLI argument.
79-
3. After running, go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules for `main`, `v1`, and `v2` have been updated.
79+
3. After running, go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules for `main`, `v2`, and `v3` have been updated.
80+
81+
Note that any updates to checks need to be backported to the `releases/v2` branch, in order to maintain the same set of names for required checks.
8082

8183
## Deprecating a CodeQL version (write access required)
8284

@@ -111,8 +113,8 @@ To deprecate an older version of the Action:
111113
- Add a changelog note announcing the deprecation.
112114
- Implement an Actions warning for customers using the deprecated version.
113115
1. Wait for the deprecation period to pass.
114-
1. Upgrade the Actions warning for customers using the deprecated version to a non-fatal error, and mention that this version of the Action is no longer supported.
115-
1. Make a PR to bump the `OLDEST_SUPPORTED_MAJOR_VERSION` in [release-branches.py](.github/actions/release-branches/release-branches.py). Once this PR is merged, the release process will no longer backport changes to the deprecated release version.
116+
1. Upgrade the Actions warning for customers using the deprecated version to a non-fatal error, and mention that this version of the Action is no longer supported.
117+
1. Make a PR to bump the `OLDEST_SUPPORTED_MAJOR_VERSION` in [releases.ini](.github/releases.ini). Once this PR is merged, the release process will no longer backport changes to the deprecated release version.
116118

117119
## Resources
118120

lib/defaults.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"bundleVersion": "codeql-bundle-v2.15.4",
3-
"cliVersion": "2.15.4",
4-
"priorBundleVersion": "codeql-bundle-v2.15.3",
5-
"priorCliVersion": "2.15.3"
2+
"bundleVersion": "codeql-bundle-v2.15.5",
3+
"cliVersion": "2.15.5",
4+
"priorBundleVersion": "codeql-bundle-v2.15.4",
5+
"priorCliVersion": "2.15.4"
66
}

0 commit comments

Comments
 (0)