-
Notifications
You must be signed in to change notification settings - Fork 1.1k
use github action to deploy to test.pypi.org and pypi.org #1038
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 all commits
b7d0796
1a32b76
5c0c786
fc0098b
35c8782
80c46f9
9ab31b9
17e8554
143d940
8cf1f75
06e5bfc
50e5aec
035acc6
44bdadf
0440fbc
262810b
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,41 @@ | ||
name: Publish distributions to PyPI (releases only) and TestPyPI (all commits) | ||
|
||
on: push | ||
|
||
jobs: | ||
build-n-publish: | ||
name: Build and publish distributions to PyPI (releases only) and TestPyPI (all commits) | ||
if: github.repository == 'pvlib/pvlib-python' | ||
runs-on: ubuntu-latest | ||
steps: | ||
# fetch all commits and tags so versioneer works | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install build tools | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools wheel | ||
|
||
- name: Build packages | ||
run: python setup.py sdist bdist_wheel | ||
|
||
- name: Publish distribution to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@master | ||
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. Should this be tagged to a version of the action instead of tracking the master branch? 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 was wondering the same thing when I copied it from the PyPA guide. That guide also used master for the other actions that we're now pinning (in part copying metpy and other examples). Either way is fine with me. |
||
with: | ||
user: __token__ | ||
password: ${{ secrets.test_pypi_password }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
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. The Test PyPI server is new to me. The PyPI guides I'm reading all suggest using it, but don't say why -- will it fail for a malformed distribution or something? Should it be followed with a quick pip install from the test server to verify that the installation works? 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 link raises a good point about race conditions when the actions for multiple PRs are running in parallel -- I'm not saying one way or the other that we should use 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 the best reason to use Test PyPI is to ensure that your distribution workflow (manual or automated) works as you expect it to. It's hard for me to imagine a situation in which we'd run into the race condition and not want to be alerted to a problem for manual fixes. The action only works on pushes to 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. Oh, I mistakenly thought 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. To be clear, the action does run on pushes to forks, but it stops before doing anything meaningful. See screen shot below for a recent history of the actions on my fork. Unfortunately it does not seem that there is a way for us to disable actions on forks, but forks may choose to disable actions in https://github.com/{username}/pvlib-python/settings/actions |
||
|
||
- name: Publish distribution to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} |
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.
Fetching all of history seems a little overkill -- is it worth it to copy metpy's approach? Or maybe fetching is cheap so let's not worry about it.
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.
It doesn't take more than a few seconds for this to run so I think we should keep it simple for now.