-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Automatically release nightly Catalyst builds on TestPyPI (#921)
Other developers, projects, CI tools, and users have often needed to use a recent development version of Catalyst, without being able to do so. The main avenue of obtaining a development version of Catalyst has been building from source. This PR adds a new action that automatically releases a snapshot of Catalyst on schedule (every night). The package version is automatically bumped (e.g. from `0.8.0-dev0` to `0.8.0-dev1`) each time this happens and the main branch updated accordingly. Testing procedure: - ~(pre-PR): test action on local fork~ - ~temporarily enable action run on PRs~ - ~(1): test action without branch push or upload~ https://github.com/PennyLaneAI/catalyst/actions/runs/9894753620 - ~(2): test action with upload~ https://github.com/PennyLaneAI/catalyst/actions/runs/9896594944 - ~(3): test action with push to branch~ (I won't be testing this one since since PR workflows don't run on a branch, but it worked on the fork.) - ~remove all temporary elements from PR~ & merge [sc-66377]
- Loading branch information
Showing
7 changed files
with
137 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Build nightly Catalyst releases for TestPyPI | ||
|
||
on: | ||
schedule: | ||
# Run every weekday at 23:40 | ||
- cron: "40 23 * * 1-5" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
setup: | ||
name: Setup the release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Catalyst repo | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.AUTO_UPDATE_VERSION_RINGO_TOKEN }} | ||
|
||
- name: Bump dev version | ||
run: | | ||
python $GITHUB_WORKSPACE/.github/workflows/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/frontend/catalyst/_version.py | ||
git commit -m "bump nightly version" | ||
git push | ||
linux-x86: | ||
name: Build on Linux x86-64 | ||
needs: [setup] | ||
uses: ./.github/workflows/build-wheel-linux-x86_64.yaml | ||
|
||
linux-aarch: | ||
name: Build on Linux aarch64 | ||
needs: [setup] | ||
uses: ./.github/workflows/build-wheel-linux-arm64.yaml | ||
|
||
macos-arm: | ||
name: Build on macOS arm64 | ||
needs: [setup] | ||
uses: ./.github/workflows/build-wheel-macos-arm64.yaml | ||
|
||
macos-x86: | ||
name: Build on macOS x86-64 | ||
needs: [setup] | ||
uses: ./.github/workflows/build-wheel-macos-x86_64.yaml | ||
|
||
upload: | ||
name: Prepare & Upload wheels to TestPyPI | ||
needs: [linux-x86, linux-aarch, macos-arm, macos-x86] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download wheels | ||
uses: actions/download-artifact@v4 | ||
with: | ||
merge-multiple: true | ||
path: dist | ||
|
||
- name: Install rename | ||
run: | | ||
sudo apt install rename | ||
- name: Prepare wheels | ||
run: | | ||
rename "s/linux/manylinux_2_28/" dist/PennyLane_Catalyst-* | ||
rename "s/macosx_14/macosx_13/" dist/PennyLane_Catalyst-* | ||
rename "s/_universal2/_x86_64/" dist/PennyLane_Catalyst-* | ||
- name: Upload wheels | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
packages-dir: dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Catalyst development version by one unit. | ||
""" | ||
|
||
import os | ||
import re | ||
|
||
version_file_path = os.path.join(os.path.dirname(__file__), "../../frontend/catalyst/_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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
Version number (major.minor.patch[-label]) | ||
""" | ||
|
||
__version__ = "0.8.0-dev" | ||
__version__ = "0.8.0-dev0" |