Skip to content

Setup workflow to publish to PyPI#114

Merged
dave-doty merged 1 commit intodevfrom
dev-publish-to-pypi
Jul 13, 2020
Merged

Setup workflow to publish to PyPI#114
dave-doty merged 1 commit intodevfrom
dev-publish-to-pypi

Conversation

@UnHumbleBen
Copy link
Copy Markdown
Collaborator

@dave-doty Can you add the necessary secrets named PYPI_USERNAME and PYPI_PASSWORD to the repositories' secrets. I tried this out with my local fork secrets and it seems pretty safe in the sense that there is no way you can see the value of the secret that you entered. Even if you try to update them, Github will not show what was the previous value of the secret.

@UnHumbleBen UnHumbleBen requested a review from dave-doty July 13, 2020 00:18
@UnHumbleBen UnHumbleBen mentioned this pull request Jul 13, 2020
Copy link
Copy Markdown
Member

@dave-doty dave-doty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the PYPI_PASSWORD and PYPI_USERNAME.

Can you double-check the comments below?

Update: Sorry, I should have added the comments before submitting the review. They are visible under the "Files changed" tab:

image

TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I typically just execute

python setup.py sdist

without bdist_wheel. What is bdist_wheel for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to be honest, I just followed the sample workflow given here: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries. Let me take a look

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, it's probably fine.

@UnHumbleBen
Copy link
Copy Markdown
Collaborator Author

Thanks for adding credentials, I just reread your emails about wanting to only publish on releases so I'm going to try to add this workflow into releases.yml file.

TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
Copy link
Copy Markdown
Member

@dave-doty dave-doty Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line (twine upload dist/*) might work here, since it has just set up a fresh environment, and presumably there will only be one file in dist/ after executing the previous line.

But when I do this locally, it doesn't work, because files build up in the dist/ subdirectory, e.g.,

scadnano-0.9.6.tar.gz
scadnano-0.9.7.tar.gz
scadnano-0.9.8.tar.gz

PyPI only lets you upload a file with a given name/version once, because there's no concept of updating a given version. If you want to change anything, you always have to create a new version. So I always just execute a command such as

twine upload dist/scadnano-0.9.8.tar.gz

if 0.9.8 is the most recent version.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try on my local fork.

Copy link
Copy Markdown
Collaborator Author

@UnHumbleBen UnHumbleBen Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow works fine for uploading future ones: https://pypi.org/project/scadnano-copy/0.9.13/#history
Workflow: https://github.com/UnHumbleBen/scadnano-python-package-1/runs/863738183?check_suite_focus=true

I made up version 0.9.13 in my local fork the action worked fine, even though I previously had 0.9.8 uploaded already

@dave-doty dave-doty merged commit 275584b into dev Jul 13, 2020
@dave-doty dave-doty deleted the dev-publish-to-pypi branch July 13, 2020 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants