Skip to content

Commit 423d14e

Browse files
authored
Merge pull request #3277 from github/mbg/ci/update-bundle-python
Install Python in `update-bundle` workflow
2 parents 862f566 + 6dd11f7 commit 423d14e

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
with open('CHANGELOG.md', 'r') as f:
10+
changelog = f.read()
11+
12+
changelog = changelog.replace('## [UNRELEASED]\n\nNo user facing changes.', '## [UNRELEASED]\n')
13+
14+
# Add the changelog note to the bottom of the "[UNRELEASED]" section.
15+
changelog = re.sub(r'\n## (\d+\.\d+\.\d+)', f'{changelog_note}\n\n## \\1', changelog, count=1)
16+
17+
with open('CHANGELOG.md', 'w') as f:
18+
f.write(changelog)

.github/workflows/update-bundle.yml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
4141
git config --global user.name "github-actions[bot]"
4242
43+
- name: Set up Python
44+
uses: actions/setup-python@v6
45+
with:
46+
python-version: '3.12'
47+
4348
- name: Set up Node.js
4449
uses: actions/setup-node@v6
4550
with:
@@ -78,28 +83,8 @@ jobs:
7883
echo "PR_URL=$pr_url" | tee -a "$GITHUB_ENV"
7984
8085
- name: Create changelog note
81-
shell: python
8286
run: |
83-
import os
84-
import re
85-
86-
# Get the PR number from the PR URL.
87-
pr_number = os.environ['PR_URL'].split('/')[-1]
88-
changelog_note = f"- Update default CodeQL bundle version to {os.environ['CLI_VERSION']}. [#{pr_number}]({os.environ['PR_URL']})"
89-
90-
# If the "[UNRELEASED]" section starts with "no user facing changes", remove that line.
91-
# Use perl to avoid having to escape the newline character.
92-
93-
with open('CHANGELOG.md', 'r') as f:
94-
changelog = f.read()
95-
96-
changelog = changelog.replace('## [UNRELEASED]\n\nNo user facing changes.', '## [UNRELEASED]\n')
97-
98-
# Add the changelog note to the bottom of the "[UNRELEASED]" section.
99-
changelog = re.sub(r'\n## (\d+\.\d+\.\d+)', f'{changelog_note}\n\n## \\1', changelog, count=1)
100-
101-
with open('CHANGELOG.md', 'w') as f:
102-
f.write(changelog)
87+
python .github/workflows/script/bundle_changelog.py
10388
10489
- name: Push changelog note
10590
run: |

0 commit comments

Comments
 (0)