Skip to content

Commit 000a447

Browse files
authored
Merge pull request #555 from github/fix/update-release
Fix release automation
2 parents 454ba4e + 486000e commit 000a447

File tree

5 files changed

+79
-14
lines changed

5 files changed

+79
-14
lines changed

.github/workflows/finalize-release.yml

+47-11
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ on:
99
inputs:
1010
ref:
1111
description: |
12-
The release branch to finalize.
12+
The ref of release to finalize (e.g., 'rc/MAJOR.MINOR.PATCH').
1313
required: true
14+
tool-ref:
15+
description: |
16+
The ref to the tooling to use for the finalize (e.g., 'rc/MAJOR.MINOR.PATCH').
17+
required: false
1418

1519
jobs:
1620
finalize-release:
@@ -20,34 +24,56 @@ jobs:
2024
- name: Determine ref
2125
env:
2226
REF_FROM_INPUT: ${{ inputs.ref }}
27+
TOOL_REF_FROM_INPUT: ${{ inputs.tool-ref }}
2328
REF_FROM_PR: ${{ github.event.pull_request.merge_commit_sha }}
2429
BASE_REF_FROM_PR: ${{ github.event.pull_request.base.ref }}
2530
run: |
2631
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
2732
echo "REF=$REF_FROM_INPUT" >> "$GITHUB_ENV"
33+
echo "TOOL_REF=$TOOL_REF_FROM_INPUT" >> "$GITHUB_ENV"
2834
echo "BASE_REF=$REF_FROM_INPUT" >> "$GITHUB_ENV"
2935
else
3036
echo "REF=$REF_FROM_PR" >> "$GITHUB_ENV"
37+
echo "TOOL_REF=$REF_FROM_PR" >> "$GITHUB_ENV"
3138
echo "BASE_REF=$BASE_REF_FROM_PR" >> "$GITHUB_ENV"
3239
fi
3340
3441
- name: Checkout
3542
uses: actions/checkout@v4
3643
with:
3744
ref: ${{ env.REF }}
45+
fetch-depth: 0
46+
path: release
47+
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
with:
51+
ref: ${{ env.TOOL_REF }}
52+
path: tooling
53+
54+
- name: Install Python
55+
uses: actions/setup-python@v4
56+
with:
57+
python-version: "3.9"
58+
59+
- name: Install dependencies
60+
run: pip install -r scripts/release/requirements.txt
61+
working-directory: tooling
3862

3963
- name: Configure git
4064
run: |
4165
git config user.name "$GITHUB_ACTOR"
4266
git config user.email "[email protected]"
67+
working-directory: release
4368

4469
- name: Update release tag
4570
run: |
4671
version=${BASE_REF#rc/}
4772
echo "Creating release tag v$version"
4873
49-
git tag -a v$version -m "Release v$version"
50-
git push -f origin v$version
74+
git tag -f -a v$version -m "Release v$version"
75+
git push --force origin v$version
76+
working-directory: release
5177

5278
- name: Finalize release
5379
env:
@@ -57,30 +83,40 @@ jobs:
5783
echo "Finalizing release v$version"
5884
5985
gh release edit "v$version" --draft=false --tag=v$version
86+
working-directory: release
6087

6188
- name: Determine if release was a hotfix release
6289
run: |
6390
version=${BASE_REF#rc/}
64-
echo "HOTFIX_RELEASE=$(python scripts/release/is-hotfix.py $version)" >> "$GITHUB_ENV"
91+
# We are running the script in the tooling directory with the release directory as the working directory
92+
echo "HOTFIX_RELEASE=$(python ../tooling/scripts/release/is-hotfix-release.py $version)" >> "$GITHUB_ENV"
93+
working-directory: release
94+
95+
- name: Determine next release version
96+
if: env.HOTFIX_RELEASE == 'false'
97+
run: |
98+
version=${BASE_REF#rc/}
99+
next_version=$(python scripts/release/next-version.py --component minor --pre-release dev -- $version)
100+
echo "NEXT_VERSION=$next_version" >> "$GITHUB_ENV"
101+
working-directory: tooling
65102

66103
- name: Bump main version
67-
if: env.HOTFIX_RELEASE == 'false'
68104
env:
69105
GH_TOKEN: ${{ github.token }}
70106
run: |
71-
version=${BASE_REF#rc/}
72-
next_version="$version-dev"
73-
echo "Bumping main version to $next_version"
107+
echo "Bumping main version to $NEXT_VERSION"
74108
75109
git switch main
76110
git pull --ff-only origin main
77111
78112
git switch -c release-automation/bump-version
79113
80-
./scripts/release/bump-version.sh "$next_version"
114+
# We are running the script in the tooling directory with the release directory as the working directory
115+
../tooling/scripts/release/bump-version.sh "$NEXT_VERSION"
81116
82117
git add -u .
83-
git commit -m "Bump version to $next_version"
118+
git commit -m "Bump version to $NEXT_VERSION"
84119
git push --set-upstream origin release-automation/bump-version
85120
86-
gh pr create --repo $GITHUB_REPOSITORY --base main --head release-automation/bump-version --body "Bump the version of main to the dev label of the just released version $next_version" --title "Bump version to $next_version"
121+
gh pr create --repo $GITHUB_REPOSITORY --base main --head release-automation/bump-version --body "Bump the version of main to $NEXT_VERSION" --title "Bump version to $NEXT_VERSION"
122+
working-directory: release

.github/workflows/update-release.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
uses: actions/checkout@v4
3232
with:
3333
fetch-depth: 0 # We need the full history to compute the changelog
34+
ref: ${{ inputs.head-sha }}
3435

3536
- name: Install Python
3637
uses: actions/setup-python@v4
@@ -59,7 +60,7 @@ jobs:
5960
--layout scripts/release/release-layout.yml \
6061
--repo "$GITHUB_REPOSITORY" \
6162
--github-token "$GITHUB_REPOSITORY:$GITHUB_TOKEN" "github/codeql-coding-standards-release-engineering:$RELEASE_ENGINEERING_TOKEN" \
62-
--skip-checkrun "release-status"
63+
--skip-checkrun "release-status" "Update Release"
6364
6465
- name: Update release notes
6566
env:

docs/user_manual.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ This section describes known failure modes for "CodeQL Coding Standards" and des
496496
| | Ouf of space | Less output. Some files may be only be partially analyzed, or not analyzed at all. | Error reported on the command line. | Increase space. If it remains an issue report space consumption issues via the CodeQL Coding Standards [bug tracker](https://github.com/github/codeql-coding-standards/issues). |
497497
| | False positives | More output. Results are reported which are not violations of the guidelines. | All reported results must be reviewed. | Report false positive issues via the CodeQL Coding Standards [bug tracker](https://github.com/github/codeql-coding-standards/issues). |
498498
| | False negatives | Less output. Violations of the guidelines are not reported. | Other validation and verification processes during software development should be used to complement the analysis performed by CodeQL Coding Standards. | Report false negative issues via the CodeQL Coding Standards [bug tracker](https://github.com/github/codeql-coding-standards/issues). |
499-
| | Modifying coding standard suite | More or less output. If queries are added to the query set more result can be reported. If queries are removed less results might be reported. | All queries supported by the CodeQL Coding Standards are listed in the release artifacts `supported_rules_list_2.25.0-dev.csv` where VERSION is replaced with the used release. The rules in the resulting Sarif file must be cross-referenced with the expected rules in this list to determine the validity of the used CodeQL suite. | Ensure that the CodeQL Coding Standards are not modified in ways that are not documented as supported modifications. |
499+
| | Modifying coding standard suite | More or less output. If queries are added to the query set more result can be reported. If queries are removed less results might be reported. | All queries supported by the CodeQL Coding Standards are listed in the release artifacts `supported_rules_list_2.25.0-dev.csv` where VERSION is replaced with the used release. The rules in the resulting Sarif file must be cross-referenced with the expected rules in this list to determine the validity of the used CodeQL suite. | Ensure that the CodeQL Coding Standards are not modified in ways that are not documented as supported modifications. |
500500
| | Incorrect deviation record specification | More output. Results are reported for guidelines for which a deviation is assigned. | Analysis integrity report lists all deviations and incorrectly specified deviation records with a reason. Ensure that all deviation records are correctly specified. | Ensure that the deviation record is specified according to the specification in the user manual. |
501501
| | Incorrect deviation permit specification | More output. Results are reported for guidelines for which a deviation is assigned. | Analysis integrity report lists all deviations and incorrectly specified deviation permits with a reason. Ensure that all deviation permits are correctly specified. | Ensure that the deviation record is specified according to the specification in the user manual. |
502502
| | Unapproved use of a deviation record | Less output. Results for guideline violations are not reported. | Validate that the deviation record use is approved by verifying the approved-by attribute of the deviation record specification. | Ensure that each raised deviation record is approved by an independent approver through an auditable process. |

scripts/release/is-hotfix-release.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def get_merge_base_of_ref() -> str:
1010
cp = run(["git", "merge-base", "HEAD", "origin/main"], capture_output=True, text=True)
1111
if cp.returncode != 0:
12-
raise RuntimeError("Failed to get merge base")
12+
raise RuntimeError(f"Failed to get merge base with reason '{cp.stderr.strip()}'")
1313
return cp.stdout.strip()
1414

1515
def get_release_branches_containing(commit: str) -> List[Version]:

scripts/release/next-version.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from semantic_version import Version
2+
import argparse
3+
4+
parser = argparse.ArgumentParser(description='Prints the next release version')
5+
parser.add_argument('-c', '--component', default="minor", help='The component to increment (major, minor, patch)')
6+
parser.add_argument('-p', '--pre-release', nargs='*', help='The pre-release label(s) (e.g. alpha, dev). Multiple labels can be specified so separate the options and the version using `--`!')
7+
parser.add_argument('-b', '--build', nargs='*', help='The build identifier(s). Multiple identifiers can be specified so separate the options and the version using `--`!')
8+
parser.add_argument('current_version', type=Version, help='The current version')
9+
10+
if __name__ == "__main__":
11+
args = parser.parse_args()
12+
version : Version = args.current_version
13+
next_version = None
14+
if args.component== "major":
15+
next_version = version.next_major()
16+
elif args.component == "minor":
17+
next_version = version.next_minor()
18+
elif args.component == "patch":
19+
next_version = version.next_patch()
20+
else:
21+
raise ValueError(f"Invalid release type: {args.release_type}")
22+
23+
if args.pre_release:
24+
next_version.prerelease = args.pre_release
25+
if args.build:
26+
next_version.build = args.build
27+
28+
print(next_version)

0 commit comments

Comments
 (0)