Skip to content

Commit

Permalink
chore: add update CMake workflow (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut authored Jun 26, 2024
1 parent 67852b1 commit 3e56e2e
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/update-cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Update CMake

on:
pull_request:
paths:
- '.github/workflows/update-cmake.yml'
- 'scripts/update_cmake_version.py'
- 'noxfile.py'
workflow_dispatch:
schedule:
- cron: '0 6 * * *' # "At 06:00 every day."

jobs:
update-cmake:
name: Update CMake
if: github.repository_owner == 'scikit-build' || github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wntrblm/[email protected]
- name: "Run update: bump CMake"
id: bump-cmake
run: |
nox --force-color -s bump
echo "version=$(nox -s cmake_version 2>/dev/null)" >> $GITHUB_OUTPUT
- run: echo "CMake version is ${{ steps.bump-cmake.outputs.version }}"

# we use this step to grab a Github App auth token, so that PRs generated by this workflow
# run the GHA tests.
- uses: actions/create-github-app-token@v1
id: app-token
if: github.ref == 'refs/heads/master' && github.repository == 'scikit-build/cmake-python-distributions'
with:
app-id: ${{ secrets.SCIKIT_BUILD_BOT_APP_ID }}
private-key: ${{ secrets.SCIKIT_BUILD_BOT_APP_PRIVATE_KEY }}

- name: Create Pull Request
if: github.ref == 'refs/heads/master' && github.repository == 'scikit-build/cmake-python-distributions'
uses: peter-evans/create-pull-request@v6
with:
commit-message: '[Bot] Update to CMake ${{ steps.bump-cmake.outputs.version }}'
title: '[Bot] Update to CMake ${{ steps.bump-cmake.outputs.version }}'
body: |
Created by update_cmake_version.py
PR generated by "Update CMake" [workflow](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
branch: update-cmake-pr
committer: "scikit-build-app-bot[bot] <173546081+scikit-build-app-bot[bot]@users.noreply.github.com>"
author: "scikit-build-app-bot[bot] <173546081+scikit-build-app-bot[bot]@users.noreply.github.com>"
token: ${{ steps.app-token.outputs.token }}
delete-branch: true
18 changes: 16 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,28 @@ def bump_openssl(session: nox.Session) -> None:
_bump(session, "OpenSSL", "openssl/openssl", "3.0", "scripts/update_openssl_version.py", files)


def _get_version() -> str:
txt = Path("pyproject.toml").read_text()
return next(iter(re.finditer(r'^version = "([\d\.]+)"$', txt, flags=re.MULTILINE))).group(1)


@nox.session(venv_backend="none")
def tag_release(session: nox.Session) -> None:
"""
Print instructions for tagging a release and pushing it to GitHub.
"""

session.log("Run the following commands to make a release:")
txt = Path("pyproject.toml").read_text()
current_version = next(iter(re.finditer(r'^version = "([\d\.]+)"$', txt, flags=re.MULTILINE))).group(1)
current_version = _get_version()
print(f"git tag --sign -m 'cmake-python-distributions {current_version}' {current_version} main")
print(f"git push origin {current_version}")


@nox.session(venv_backend="none")
def cmake_version(session: nox.Session) -> None: # noqa: ARG001
"""
Print upstream cmake version.
"""

current_version = _get_version()
print(".".join(current_version.split(".")[:3]))

0 comments on commit 3e56e2e

Please sign in to comment.