Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate nightly releases on TestPyPI #6010

Merged
merged 7 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/scripts/set_nightly_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2024 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
This module bumps the PennyLane development version by one unit.
"""

import os
import re

version_file_path = os.path.join(os.path.dirname(__file__), "../../../pennylane/_version.py")

assert os.path.isfile(version_file_path)

with open(version_file_path, "r+", encoding="UTF-8") as f:
lines = f.readlines()

version_line = lines[-1]
assert "__version__ = " in version_line

pattern = r"(\d+).(\d+).(\d+)-dev(\d+)"
match = re.search(pattern, version_line)
assert match

major, minor, bug, dev = match.groups()

replacement = f'__version__ = "{major}.{minor}.{bug}-dev{int(dev)+1}"\n'
lines[-1] = replacement

f.seek(0)
f.writelines(lines)
f.truncate()
48 changes: 48 additions & 0 deletions .github/workflows/upload-nightly-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build nightly PennyLane releases for TestPyPI

on:
schedule:
# Run every weekday at 5:50 EDT (cron is in UTC)
- cron: "50 9 * * 1-5"
workflow_dispatch:

jobs:
setup:
name: Setup the release
runs-on: ubuntu-latest
steps:
- name: Checkout PennyLane repo
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.NIGHTLY_VERSION_UPDATE_DEPLOY_KEY }}

- name: Bump dev version
run: |
python $GITHUB_WORKSPACE/.github/workflows/scripts/set_nightly_version.py

- name: Push new version
run: |
git config --global user.email '${{ secrets.AUTO_UPDATE_VERSION_RINGO_EMAIL }}'
git config --global user.name "ringo-but-quantum"
git add $GITHUB_WORKSPACE/pennylane/_version.py
git commit -m "[no ci] bump nightly version"
git push

upload:
name: Upload wheels to TestPyPI
needs: [setup]
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Build wheels
run: |
python -m pip install build
python -m build --wheel --outdir dist

- name: Upload wheels
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist
2 changes: 1 addition & 1 deletion pennylane/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.38.0-dev"
__version__ = "0.38.0-dev0"
Loading