-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add GitHub action for publishing artifacts to PyPI #5244
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
Changes from 17 commits
eecf2e9
f62aa07
15dc8fe
652c1e3
9217924
1abd629
f6c808b
a9c5da0
1b9544c
5d201da
73f0467
01ff602
a97181e
43d8ed7
844016b
f503198
c44638f
e883bf1
f6e3153
a4607b1
b622462
7398dd8
7cb71e7
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Build and Upload xarray to PyPI | ||
on: | ||
release: | ||
types: | ||
- published | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-artifacts: | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'pydata/xarray' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install setuptools setuptools-scm wheel twine check-manifest | ||
|
||
- name: Build tarball and wheels | ||
run: | | ||
git clean -xdf | ||
git restore -SW . | ||
python -m build --sdist --wheel . | ||
|
||
- name: Check built artifacts | ||
run: | | ||
python -m twine check dist/* | ||
pwd | ||
if [ -f dist/xarray-0.0.0.tar.gz ]; then | ||
echo "❌ INVALID VERSION NUMBER" | ||
exit 1 | ||
else | ||
echo "✅ Looks good" | ||
fi | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: releases | ||
path: dist | ||
|
||
test-built-dist: | ||
needs: build-artifacts | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-python@v2 | ||
name: Install Python | ||
with: | ||
python-version: 3.8 | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: releases | ||
path: dist | ||
- name: List contents of built dist | ||
run: | | ||
ls -ltrh | ||
ls -ltrh dist | ||
|
||
- name: Install built artifacts | ||
run: | | ||
python -m pip install dist/*.tar.gz | ||
python -m xarray.util.print_versions | ||
|
||
upload-to-pypi: | ||
needs: test-built-dist | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: releases | ||
path: dist | ||
|
||
- name: Publish package to TestPyPI | ||
uses: pypa/[email protected] | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.TESTPYPI_TOKEN }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
verbose: true | ||
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. This will be triggered on every push event on the master branch and release tag... Should we constrain this to be triggered on push events on the master branch only? 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 think we should include tags but not releases (which are generated via the web page). That way, we can check the wheels on TestPyPI before creating the release and uploading to PyPI. 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. This should be resolved by the latest commit... |
||
|
||
- name: Publish package to PyPI | ||
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') | ||
keewis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uses: pypa/[email protected] | ||
andersy005 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
andersy005 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
skip_existing: true | ||
verbose: true |
Uh oh!
There was an error while loading. Please reload this page.
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.
I usually use
created
here, but this probably doesn't make much of a difference since we don't use "draft releases" (and I can't seem to find a page which explains the difference between the "activity types")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.
Not sure if you've seen this page already. There's this note: