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

Upload wheels to PyPI from GitHub workflows #220

Merged
merged 35 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ca878b2
Upload linux wheel
chaeyeunpark Feb 1, 2022
1c31f13
Always upload wheel
chaeyeunpark Feb 1, 2022
cce01cb
Update credential
chaeyeunpark Feb 1, 2022
6f1020a
Upload always
chaeyeunpark Feb 1, 2022
8632deb
Also upload window wheel
chaeyeunpark Feb 1, 2022
c8886eb
We have to use a separate workflow
chaeyeunpark Feb 1, 2022
c3e06b9
Upload window wheel
chaeyeunpark Feb 1, 2022
3fc20bc
One more time
chaeyeunpark Feb 1, 2022
32459ae
mkdir before download
chaeyeunpark Feb 1, 2022
05f344e
Okay
chaeyeunpark Feb 1, 2022
79afb96
Directly upload zip
chaeyeunpark Feb 1, 2022
9177b29
fix path
chaeyeunpark Feb 1, 2022
f688cca
Specify dir
chaeyeunpark Feb 1, 2022
691dd13
Pleas
chaeyeunpark Feb 1, 2022
2af04ee
Plea
chaeyeunpark Feb 1, 2022
c1eff3f
ple
chaeyeunpark Feb 2, 2022
41f069f
Update
chaeyeunpark Feb 2, 2022
e6adede
Upload all wheels
chaeyeunpark Feb 2, 2022
f7322f0
Fix for codefactor
chaeyeunpark Feb 2, 2022
dea8be5
Fix rc builds
chaeyeunpark Feb 2, 2022
122a12e
Auto update dev version
chaeyeunpark Feb 2, 2022
38f749a
Correctly push
chaeyeunpark Feb 2, 2022
22af685
Update
chaeyeunpark Feb 2, 2022
519c259
yaml update
chaeyeunpark Feb 2, 2022
c925916
Use branch
chaeyeunpark Feb 2, 2022
d2ef9cc
Update
chaeyeunpark Feb 2, 2022
bd3777a
Update bash script
chaeyeunpark Feb 2, 2022
22451e4
Auto update version
chaeyeunpark Feb 2, 2022
a72486b
One more update
chaeyeunpark Feb 2, 2022
9814a16
Merge branch 'ci_upload_pypi' of github.com:PennyLaneAI/pennylane-lig…
chaeyeunpark Feb 2, 2022
93b7a5a
Merge remote-tracking branch 'origin/master' into ci_upload_pypi
chaeyeunpark Feb 2, 2022
15927b1
uploade wheels to pypi not in PR
chaeyeunpark Feb 3, 2022
5020fcb
Merge remote-tracking branch 'origin/master' into ci_upload_pypi
chaeyeunpark Feb 8, 2022
c6b6f06
Auto update version
chaeyeunpark Feb 8, 2022
613035e
CHANGELOG updated
chaeyeunpark Feb 8, 2022
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
4 changes: 4 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### Improvements

* Set GitHub workflow to upload wheels to Test PyPI [(#220)](https://github.com/PennyLaneAI/pennylane-lightning/pull/220)

### Documentation

### Bug fixes
Expand All @@ -14,6 +16,8 @@

This release contains contributions from (in alphabetical order):

Chae-Yeun Park

---

# Release 0.21.0
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/dev_version_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2022 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.
import argparse
from pathlib import Path
import importlib

import re

VERSION_FILE_PATH = 'pennylane_lightning/_version.py'

rgx_ver = re.compile('^__version__ = \"(.*?)\"$')

rgx_dev_ver = re.compile('^(\d*\.\d*\.\d*)-dev(\d*)$')

def extract_version(package_path):
with package_path.joinpath(VERSION_FILE_PATH).open('r') as f:
for line in f.readlines():
if line.startswith('__version__'):
line = line.strip()
m = rgx_ver.match(line)
return m.group(1)
raise ValueError("Cannot parse version")

def is_dev(version_str):
m = rgx_dev_ver.fullmatch(version_str)
if m:
return True
else:
return False

def update_dev_version(package_path, version_str):
m = rgx_dev_ver.fullmatch(version_str)
if m.group(2) == '':
curr_dev_ver = 0
else:
curr_dev_ver = int(m.group(2))

new_version_str = '{}-dev{}'.format(m.group(1), str(curr_dev_ver + 1))

lines = []
with package_path.joinpath(VERSION_FILE_PATH).open('r') as f:
for line in f.readlines():
if not line.startswith('__version__'):
lines.append(line)
else:
lines.append(f'__version__ = \"{new_version_str}\"\n')

with package_path.joinpath(VERSION_FILE_PATH).open('w') as f:
f.write(''.join(lines))


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--pr-path", dest = "pr", type=str, required=True, help="Path to the PR dir")
parser.add_argument("--master-path", dest = "master", type=str, required=True, help="Path to the master dir")

args = parser.parse_args()

pr_version = extract_version(Path(args.pr))
master_version = extract_version(Path(args.master))

if pr_version == master_version:
if is_dev(pr_version):
print("Automatically update version string.")
update_dev_version(Path(args.pr), pr_version)
else:
print("Even though version of this PR is different from the master, as the PR is not dev, we do nothing.")
else:
print("Version of this PR is already different from master. Do nothing.")
44 changes: 44 additions & 0 deletions .github/workflows/update_dev_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Update dev version automatically
on:
pull_request:

jobs:
update-dev-version:
name: Update version for development branches
runs-on: ubuntu-latest
steps:

- name: Checkout PennyLane-Lightning master
uses: actions/checkout@v2
with:
ref: master
path: main

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'

- name: Checkout PennyLane-Lightning PR
uses: actions/checkout@v2
with:
token: ${{ secrets.DEV_TOKEN }}
ref: ${{ github.head_ref }}
path: pr

- name: Run version update script
run: >
python3 pr/.github/workflows/dev_version_script.py
--pr-path "./pr" --master-path "./main"

- name: Commit and push changes
if:
run: |
cd ./pr
if [[ -n $(git status -s) ]]; then
git config --local user.email "chae-yeun@xanadu.ai"
git config --local user.name "Dev version update bot"
git add .
git commit -m 'Auto update version'
git push
fi
17 changes: 17 additions & 0 deletions .github/workflows/wheel_linux_aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,20 @@ jobs:
with:
name: ${{ runner.os }}-wheels.zip
path: ./wheelhouse/*.whl

upload-pypi:
needs: linux-wheels-aarch64
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master'}}
steps:
- uses: actions/download-artifact@v2
with:
name: Linux-wheels.zip
path: dist

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
17 changes: 17 additions & 0 deletions .github/workflows/wheel_linux_ppc64le.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,20 @@ jobs:
with:
name: ${{ runner.os }}-wheels.zip
path: ./wheelhouse/*.whl

upload-pypi:
needs: linux-wheels-ppc64le
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master'}}
steps:
- uses: actions/download-artifact@v2
with:
name: Linux-wheels.zip
path: dist

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
17 changes: 17 additions & 0 deletions .github/workflows/wheel_linux_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,20 @@ jobs:
with:
name: ${{ runner.os }}-wheels.zip
path: ./wheelhouse/*.whl

upload-pypi:
needs: linux-wheels-x86-64
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master'}}
steps:
- uses: actions/download-artifact@v2
with:
name: Linux-wheels.zip
path: dist

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
17 changes: 17 additions & 0 deletions .github/workflows/wheel_macos_arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,20 @@ jobs:
with:
name: ${{ runner.os }}-wheels.zip
path: ./wheelhouse/*.whl

upload-pypi:
needs: mac-wheels-arm64
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master'}}
steps:
- uses: actions/download-artifact@v2
with:
name: macOS-wheels.zip
path: dist

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
17 changes: 17 additions & 0 deletions .github/workflows/wheel_macos_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,20 @@ jobs:
with:
name: ${{ runner.os }}-wheels.zip
path: ./wheelhouse/*.whl

upload-pypi:
needs: mac-wheels-x86
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master' }}
steps:
- uses: actions/download-artifact@v2
with:
name: macOS-wheels.zip
path: dist

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
19 changes: 18 additions & 1 deletion .github/workflows/wheel_noarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,22 @@ jobs:
- uses: actions/upload-artifact@v2
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master' }}
with:
name: pure-python-wheels
name: pure-python-wheels.zip
path: main/dist/*.whl

upload-pypi:
needs: build-pure-python-wheel
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master'}}
steps:
- uses: actions/download-artifact@v2
with:
name: pure-python-wheels.zip
path: dist

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
17 changes: 17 additions & 0 deletions .github/workflows/wheel_win_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,20 @@ jobs:
with:
name: ${{ runner.os }}-wheels.zip
path: ./wheelhouse/*.whl

upload-pypi:
needs: win-wheels
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master'}}
steps:
- uses: actions/download-artifact@v2
with:
name: Windows-wheels.zip
path: dist

- name: Upload wheels to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
2 changes: 1 addition & 1 deletion pennylane_lightning/_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.22.0-dev"
__version__ = "0.22.0-dev1"