Skip to content

Commit feab4e0

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

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

.github/workflows/update-cmake.yml

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