-
Notifications
You must be signed in to change notification settings - Fork 225
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
Publish releases to PyPI via a GitHub Action #674
Changes from 6 commits
611f41b
6b36055
6e263ac
75cb2f9
c5aeb7a
46a8725
b3aa94e
8dd9e67
ac14556
ec90a8d
479a435
ce20eaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ jobs: | |
|
||
- name: Build Python package | ||
run: | | ||
make build_pypi | ||
make build | ||
|
||
|
||
docs: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This github action builds Alibi Detect and publishes it to PyPI. | ||
# It is only run when a new "release" is published via GitHub here: | ||
# https://github.com/SeldonIO/alibi-detect/releases | ||
name: Publish release to PyPI | ||
|
||
# Only run when tags starting with "v" are pushed | ||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-and-publish: | ||
name: Build and publish | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
# Setup Python | ||
- uses: actions/checkout@master | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.9 | ||
|
||
# Build | ||
- name: Build a binary wheel and a source tarball | ||
run: make build | ||
|
||
# Get the PEP440 compliant version number (so we can check version is installable) | ||
- name: Get 📦 version number | ||
id: get_version | ||
run: echo "PACKAGE_VERS=$(python setup.py --version)" >> $GITHUB_ENV | ||
|
||
# Publish the associated tag to PyPI | ||
- name: Publish 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
# Wait for a while to give PyPI time to update (otherwise the pip install might fail) | ||
- name: Sleep for 10 minutes | ||
shell: bash | ||
run: sleep 10m | ||
|
||
# Install from PyPI and test | ||
- name: Install 📦 from PyPI and test | ||
run: | | ||
make clean | ||
python -m pip install alibi-detect==${{ env.PACKAGE_VERS }} | ||
python -c "from alibi_detect.cd import KSDrift" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This github action builds Alibi Detect and publishes it to Test PyPI. | ||
# It is only run when a new tag is pushed to github. | ||
name: Publish release to Test PyPI | ||
|
||
# Only run when tags starting with "v" are pushed | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build-and-publish: | ||
name: Build and publish | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
# Setup Python | ||
- uses: actions/checkout@master | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.9 | ||
|
||
# Build | ||
- name: Build a binary wheel and a source tarball | ||
run: make build | ||
|
||
# Publish to Test PyPI | ||
- name: Publish 📦 to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
|
||
# Get the PEP440 compliant version number (so we can check version is installable) | ||
- name: Get 📦 version number | ||
id: get_version | ||
run: echo "PACKAGE_VERS=$(python setup.py --version)" >> $GITHUB_ENV | ||
|
||
# Wait for a while to give PyPI time to update (otherwise the pip install might fail) | ||
- name: Sleep for 10 minutes | ||
shell: bash | ||
run: sleep 10m | ||
|
||
# Install from Test PyPI and test | ||
- name: Install 📦 from PyPI and test | ||
run: | | ||
make clean | ||
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple alibi-detect==${{ env.PACKAGE_VERS }} | ||
python -c "from alibi_detect.cd import KSDrift" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change this to have imports like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re stdout I think this line was stdout:
In b3aa94e I've changed to the imports you suggested and added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re stderr I'm not sure a python error would actually fail the GA step. Will look into this. Think we're pretty much there after that! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK seems to fail as desired: |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
# 2) we can import it in setup.py for the same reason | ||
# 3) we can import it into your module module | ||
|
||
__version__ = "0.11.0dev" | ||
__version__ = "0.10.5-alpha5" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: revert before merging |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools~=65.5", | ||
"wheel~=0.38", | ||
] | ||
build-backend = "setuptools.build_meta" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 minutes sounds long, usually I can install almost straight away. Not sure though if worth trying programmatically installing (e.g. in a while loop) until it succeeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a
while
loop not be essentially the same thing though? i.e. wouldn't we have to set some sort of break condition to prevent an infinite loop, so we'd still have to set a time or number of attempts limit?I've reduced it to 5 mins now. Perhaps we reduce it even more to say 1 or 2 mins, and then increase it if we regularly get failures? An occasional failure would not be the end of the world since the publish still would still have been done, and the user could check manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoyingly 1 minute wasn't enough!
https://github.com/ascillitoe/alibi-detect/actions/runs/3496674516/jobs/5854858932
I've settled on 3 for now... we can add a fetch a cup of tea 🍵 stage to the instructions?!