Skip to content

Commit c9f82f2

Browse files
committed
Move python script to file
1 parent 33684ef commit c9f82f2

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
import re
3+
4+
# Get the PR number from the PR URL.
5+
pr_number = os.environ['PR_URL'].split('/')[-1]
6+
changelog_note = f"- Update default CodeQL bundle version to {os.environ['CLI_VERSION']}. [#{pr_number}]({os.environ['PR_URL']})"
7+
8+
# If the "[UNRELEASED]" section starts with "no user facing changes", remove that line.
9+
# Use perl to avoid having to escape the newline character.
10+
with open('CHANGELOG.md', 'r') as f:
11+
changelog = f.read()
12+
13+
changelog = changelog.replace('## [UNRELEASED]\n\nNo user facing changes.', '## [UNRELEASED]\n')
14+
15+
# Add the changelog note to the bottom of the "[UNRELEASED]" section.
16+
changelog = re.sub(r'\n## (\d+\.\d+\.\d+)', f'{changelog_note}\n\n## \\1', changelog, count=1)
17+
18+
with open('CHANGELOG.md', 'w') as f:
19+
f.write(changelog)

.github/workflows/update-bundle.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,8 @@ jobs:
8383
echo "PR_URL=$pr_url" | tee -a "$GITHUB_ENV"
8484
8585
- name: Create changelog note
86-
shell: python
8786
run: |
88-
import os
89-
import re
90-
91-
# Get the PR number from the PR URL.
92-
pr_number = os.environ['PR_URL'].split('/')[-1]
93-
changelog_note = f"- Update default CodeQL bundle version to {os.environ['CLI_VERSION']}. [#{pr_number}]({os.environ['PR_URL']})"
94-
95-
# If the "[UNRELEASED]" section starts with "no user facing changes", remove that line.
96-
# Use perl to avoid having to escape the newline character.
97-
98-
with open('CHANGELOG.md', 'r') as f:
99-
changelog = f.read()
100-
101-
changelog = changelog.replace('## [UNRELEASED]\n\nNo user facing changes.', '## [UNRELEASED]\n')
102-
103-
# Add the changelog note to the bottom of the "[UNRELEASED]" section.
104-
changelog = re.sub(r'\n## (\d+\.\d+\.\d+)', f'{changelog_note}\n\n## \\1', changelog, count=1)
105-
106-
with open('CHANGELOG.md', 'w') as f:
107-
f.write(changelog)
87+
python .github/workflows/script/bundle_changelog.py
10888
10989
- name: Push changelog note
11090
run: |

0 commit comments

Comments
 (0)