Skip to content

Commit ae4c305

Browse files
committed
chore: add update CMake workflow
1 parent 67852b1 commit ae4c305

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

.github/workflows/update-cmake.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Update CMake
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/update-cmake.yml'
7+
- 'scripts/update_cmake_version.py'
8+
- 'noxfile.py'
9+
workflow_dispatch:
10+
schedule:
11+
- cron: '0 6 * * *' # "At 06:00 every day."
12+
13+
jobs:
14+
update-cmake:
15+
name: Update CMake
16+
if: github.repository_owner == 'scikit-build' || github.event_name != 'schedule'
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: wntrblm/[email protected]
21+
- name: "Run update: bump CMake"
22+
id: bump-cmake
23+
run: |
24+
nox --force-color -s bump
25+
echo "version=$(nox -s cmake_version 2>/dev/null)" >> $GITHUB_OUTPUT
26+
- run: echo "CMake version is ${{ steps.bump-cmake.outputs.version }}"
27+
28+
# we use this step to grab a Github App auth token, so that PRs generated by this workflow
29+
# run the GHA tests.
30+
- uses: tibdex/github-app-token@v2
31+
id: generate-token
32+
if: github.ref == 'refs/heads/master' && github.repository == 'scikit-build/cmake-python-distributions'
33+
with:
34+
app_id: ${{ secrets.SCIKIT_BUILD_BOT_APP_ID }}
35+
private_key: ${{ secrets.SCIKIT_BUILD_BOT_APP_PRIVATE_KEY }}
36+
37+
- name: Create Pull Request
38+
if: github.ref == 'refs/heads/master' && github.repository == 'scikit-build/cmake-python-distributions'
39+
uses: peter-evans/create-pull-request@v6
40+
with:
41+
commit-message: '[Bot] Update to CMake ${{ steps.bump-cmake.outputs.version }}'
42+
title: '[Bot] Update to CMake ${{ steps.bump-cmake.outputs.version }}'
43+
body: |
44+
Created by update_cmake_version.py
45+
46+
PR generated by "Update CMake" [workflow](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
47+
branch: update-cmake-pr
48+
committer: "scikit-build-bot[bot] <83877280+scikit-build-bot[bot]@users.noreply.github.com>"
49+
author: "scikit-build-bot[bot] <83877280+scikit-build-bot[bot]@users.noreply.github.com>"
50+
token: ${{ steps.generate-token.outputs.token }}
51+
delete-branch: true

noxfile.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,28 @@ def bump_openssl(session: nox.Session) -> None:
157157
_bump(session, "OpenSSL", "openssl/openssl", "3.0", "scripts/update_openssl_version.py", files)
158158

159159

160+
def _get_version() -> str:
161+
txt = Path("pyproject.toml").read_text()
162+
return next(iter(re.finditer(r'^version = "([\d\.]+)"$', txt, flags=re.MULTILINE))).group(1)
163+
164+
160165
@nox.session(venv_backend="none")
161166
def tag_release(session: nox.Session) -> None:
162167
"""
163168
Print instructions for tagging a release and pushing it to GitHub.
164169
"""
165170

166171
session.log("Run the following commands to make a release:")
167-
txt = Path("pyproject.toml").read_text()
168-
current_version = next(iter(re.finditer(r'^version = "([\d\.]+)"$', txt, flags=re.MULTILINE))).group(1)
172+
current_version = _get_version()
169173
print(f"git tag --sign -m 'cmake-python-distributions {current_version}' {current_version} main")
170174
print(f"git push origin {current_version}")
175+
176+
177+
@nox.session(venv_backend="none")
178+
def cmake_version(session: nox.Session) -> None: # noqa: ARG001
179+
"""
180+
Print upstream cmake version.
181+
"""
182+
183+
current_version = _get_version()
184+
print(".".join(current_version.split(".")[:3]))

0 commit comments

Comments
 (0)