Skip to content

Commit a42c9a2

Browse files
committed
update required checks script to handle release branches
1 parent a110746 commit a42c9a2

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
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 = 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/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

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ To deprecate an older version of the Action:
111111
- Add a changelog note announcing the deprecation.
112112
- Implement an Actions warning for customers using the deprecated version.
113113
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.
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 [releases.ini](.github/releases.ini). Once this PR is merged, the release process will no longer backport changes to the deprecated release version.
116116

117117
## Resources
118118

0 commit comments

Comments
 (0)