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

Create publish.yml #433

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Create publish.yml #433

wants to merge 1 commit into from

Conversation

kousu
Copy link

@kousu kousu commented May 17, 2022

This GitHub Action builds wheels and sdists and pushes them to GitHub's releases page and PyPI. All you have to do is go to New Release, fill in a version tag like "v0.1.1", click Publish, and a couple minutes later the .whl and .tar.gz will be up on Releases and on PyPI.

To get PyPI working, get a PyPI token, give it to GitHub here named PYPI_TOKEN.

Will help to fix #432

To get a feel for it, you can see examples of how this looks in practice at

And the kinds of outputs it makes at

This GitHub Action builds wheels and sdists and pushes them to GitHub's releases page and PyPI. All you have to do is go to [New Release](https://github.com/voxelmorph/voxelmorph/releases/new), fill in a version tag like "v0.9.1", click Publish, and a couple minutes later the .whl and .tar.gz will be up on [Releases](https://github.com/voxelmorph/voxelmorph/releases) and on [PyPI](https://pypi.org/project/voxelmorph).

To get PyPI working as well, [get a PyPI token](https://pypi.org/manage/account/token/), give it to GitHub [here](https://github.com/voxelmorph/voxelmorph/settings/secrets/actions) named `PYPI_TOKEN`.

Fixes voxelmorph#432
@kousu
Copy link
Author

kousu commented May 17, 2022

By the way, I recommend using a 'rc' tag like "v0.1.1rc1" to get the hang of the process the first few tries (because you never can reuse tags on pypi).

Thanks for taking the time to consider this!

@ahoopes
Copy link
Collaborator

ahoopes commented Jun 9, 2022

thanks @kousu this is super useful! you might have noticed we just uploaded a new version (0.2) to pypi, but we're happy to include this for an upcoming 0.3 release. I'm not very familiar with the github action builds, but we'll take a look into it and try to get things integrated

@kousu
Copy link
Author

kousu commented Jun 9, 2022

Great! I think it should be pretty straight forward, but let me know if I can give you a hand figuring it out.

By the way I just noticed you're using

voxelmorph/setup.py

Lines 14 to 23 in a746f77

# extract the current version
init_file = base_dir.joinpath('voxelmorph/__init__.py')
init_text = open(init_file, 'rt').read()
pattern = r"^__version__ = ['\"]([^'\"]*)['\"]"
match = re.search(pattern, init_text, re.M)
if not match:
raise RuntimeError(f'Unable to find __version__ in {init_file}.')
version = match.group(1)
if isinstance(packaging.version.parse(version), packaging.version.LegacyVersion):
raise RuntimeError(f'Invalid version string {version}.')

instead of setuptools-scm. That means making a release means you need to first edit your version then make sure to tag the release with the same version here on github. Which is I suppose what you're already doing? But I wrote this, especially this line

prerelease: ${{ contains(github.ref, 'rc') || contains(github.ref, 'dev') }}

with setuptools-scm in mind. It still works as expected so long as you keep your __version__ and git tags in sync, but it's just a bit more reliable with setuptools-scm, and it means my instruction to "All you have to do is go to New Release, fill in a version tag like "v0.1.1"," isn't quite true.

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.

Update PyPI Release
2 participants