Skip to content

Commit c956b2d

Browse files
committed
Add prepare release workflow
1 parent a52d363 commit c956b2d

3 files changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "Prepare CodeQL Coding Standards release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: |
8+
The version to release (MUST follow semantic versioning).
9+
required: true
10+
ref:
11+
description: |
12+
The git commit, branch, or tag to release from.
13+
required: true
14+
15+
env:
16+
RELEASE_VERSION: ${{ github.event.inputs.version }}
17+
18+
jobs:
19+
prepare-release:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
with:
25+
ref: ${{ github.event.inputs.ref }}
26+
27+
- name: Install Python
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: "3.9"
31+
32+
- name: Install release script dependencies
33+
run: pip install -r scripts/release/requirements.txt
34+
35+
- name: Validate version
36+
run: |
37+
scripts/release/validate-version.py "$RELEASE_VERSION"
38+
39+
- name: Create release branch
40+
run: |
41+
git switch -c rc/$RELEASE_VERSION
42+
git push --set-upstream origin rc/$RELEASE_VERSION
43+
44+
- name: Update user manual version
45+
run: |
46+
find docs -name 'user_manual.md' | xargs sed -i "s/code-scanning-cpp-query-pack-.*\.zip\`/code-scanning-cpp-query-pack-$RELEASE_VERSION.zip\`/"
47+
find docs -name 'user_manual.md' | xargs sed -i "s/supported_rules_list_.*\.csv\`/supported_rules_list_$RELEASE_VERSION.csv\`/"
48+
find docs -name 'user_manual.md' | xargs sed -i "s/supported_rules_list_.*\.md\`/supported_rules_list_$RELEASE_VERSION.md\`/"
49+
find docs -name 'user_manual.md' | xargs sed -i "s/user_manual_.*\.md\`/user_manual_$RELEASE_VERSION.md\`/"
50+
find docs -name 'user_manual.md' | xargs sed -i "s/This user manual documents release \`.*\` of/This user manual documents release \`$RELEASE_VERSION\` of/"
51+
52+
- name: Create release PR
53+
uses: peter-evans/create-pull-request@v4
54+
with:
55+
title: "Release $RELEASE_VERSION."
56+
body: "This PR releases codeql-coding-standards version $RELEASE_VERSION."
57+
commit-message: "Release $RELEASE_VERSION."
58+
delete-branch: true
59+
branch: "rc/$RELEASE_VERSION"
60+
61+

scripts/release/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semantic-version==2.10.0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import semantic_version # type: ignore
2+
from typing import Literal
3+
4+
def main(args : list[str]) -> Literal[1, 0]:
5+
if len(args) != 2:
6+
print("Error: incorrect number of arguments", file=sys.stderr)
7+
print(f"Usage: {args[0]} <version>", file=sys.stderr)
8+
return 1
9+
10+
try:
11+
semantic_version.Version.parse(args[1]) # type: ignore
12+
return 0
13+
except ValueError as e:
14+
print(f"Error: invalid version: {e}", file=sys.stderr)
15+
return 1
16+
17+
18+
if __name__ == '__main__':
19+
import sys
20+
sys.exit(main(sys.argv))

0 commit comments

Comments
 (0)