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

Add GitHub action for publishing artifacts to PyPI #5244

Merged
merged 23 commits into from
May 6, 2021
Merged
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
eecf2e9
Add GitHub action for publishing artifacts to PyPI
andersy005 May 2, 2021
f62aa07
Attempt at installing built artifacts
andersy005 May 2, 2021
15dc8fe
Add job for publishing to PyPI
andersy005 May 2, 2021
652c1e3
Remove git describe and put fetch-depth back
andersy005 May 2, 2021
9217924
remove fetch-depth
andersy005 May 2, 2021
1abd629
Remove push and pull_request event triggers
andersy005 May 2, 2021
f6c808b
Merge branch 'master' of github.com:pydata/xarray into pypi-release-v…
andersy005 May 2, 2021
a9c5da0
[skip-ci] Use python -m build
andersy005 May 3, 2021
1b9544c
[skip-ci] Set user to __token__
andersy005 May 3, 2021
5d201da
[skip-ci] Fetch all history
andersy005 May 3, 2021
73f0467
[skip-ci] Remove debugging push event trigger
andersy005 May 3, 2021
01ff602
[skip-ci] Use single job
andersy005 May 3, 2021
a97181e
Merge branch 'master' of github.com:pydata/xarray into pypi-release-v…
andersy005 May 6, 2021
43d8ed7
Add step for uploading to testPyPI
andersy005 May 6, 2021
844016b
[skip-ci] Disable if for debugging
andersy005 May 6, 2021
f503198
Remove debugging statements
andersy005 May 6, 2021
c44638f
[skip-ci]
andersy005 May 6, 2021
e883bf1
Fix github.event_name
andersy005 May 6, 2021
f6e3153
[skip-ci]
andersy005 May 6, 2021
a4607b1
Install uploaded package
andersy005 May 6, 2021
b622462
[skip-ci]
andersy005 May 6, 2021
7398dd8
[skip-ci] Move TestPyPI steps in `test-built-dist` job
andersy005 May 6, 2021
7cb71e7
[skip-ci] Make `if` condition global
andersy005 May 6, 2021
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
84 changes: 84 additions & 0 deletions .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Build and Upload xarray to PyPI
on:
release:
types:
- published
Copy link
Collaborator

@keewis keewis May 6, 2021

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")

Copy link
Member Author

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:

Note: The prereleased type will not trigger for pre-releases published from draft releases, but the published type will trigger. If you want a workflow to run when stable and pre-releases publish, subscribe to published instead of released and prereleased.




jobs:
build-artifacts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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 setup.py sdist bdist_wheel
python -m pip wheel . -w dist --no-deps
andersy005 marked this conversation as resolved.
Show resolved Hide resolved

- name: Test the 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

upload-to-pypi:
needs: build-artifacts
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
andersy005 marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/download-artifact@v2
with:
name: releases
path: dist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
andersy005 marked this conversation as resolved.
Show resolved Hide resolved
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
andersy005 marked this conversation as resolved.
Show resolved Hide resolved
skip_existing: true
verbose: true