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

[MRG] Travis: Deploy releases to pypi #301

Merged
merged 5 commits into from
Nov 18, 2019
Merged

Conversation

manics
Copy link
Member

@manics manics commented Nov 10, 2019

Release tagged builds to PyPi using Travis.

A matrix build will normally deploy multiple times. The usual way of deploying once is to use either skip_existing: true or a conditional that matches one of the jobs. The downside is that the deploy only depends on whether that particular job passes, other jobs in the matrix may fail.

I think using build stages is better because the deploy only happens if all matrix jobs pass. It's also clearer in travis since the deploy runs as it's own job.

I've tested this on testpypi:

Next steps:

  • Either add a secret environment variable PYPI_TOKEN to Travis or add an encrypted secret to travis.yml

Related:

@betatim
Copy link
Member

betatim commented Nov 11, 2019

Looks good to me!

Copy link
Member

@consideRatio consideRatio left a comment

Choose a reason for hiding this comment

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

I really like having build stages, +100 for using them!

I'd like to see that the nightly build is allowed to fail, and that it is put last to make everything else complete faster as a final job that is allowed to fail doesn't need to finish for the travis build as a whole can report success. See for example https://docs.travis-ci.com/user/customizing-the-build/#allow_failures-examples for a not obvious example, and combine that with the fast_finish thing I documented in the z2jh .travis.yml: https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/04f8a1e1546dc79a4fecc13b62bb4fc15c2992ba/.travis.yml#L68-L72

.travis.yml Outdated Show resolved Hide resolved
@manics
Copy link
Member Author

manics commented Nov 13, 2019

@consideRatio How does this look?

@consideRatio
Copy link
Member

consideRatio commented Nov 13, 2019

@manics this LGTM! Is the token stuff setup?

@manics
Copy link
Member Author

manics commented Nov 13, 2019

@consideRatio No! Someone with access tothe PyPi project needs to add the token either in the Travis web ui or by adding a secret to .travis.yml. We can either wait, or merge and sort out the token separately since it only takes effect on a tag. I tested it on testpypi but probably best to test again with an RC just in case.

@consideRatio
Copy link
Member

@manics i was a maintainer but not an owner so I cannot create such token. What path do you recommend to take regarding adding it to the web ui of travis or adding it as a encrypted secret in .travis.yml ?

@choldgraf or @minrk can perhaps help out with permissions

@choldgraf
Copy link
Member

@consideRatio you are now an owner!

@manics
Copy link
Member Author

manics commented Nov 14, 2019

@consideRatio
Creating the token:
Go to https://pypi.org/manage/project/{pypi-repo}/settings/
API TokenCreate a token for {pypi-repo}, Name can be anything, Scope: just the repository for now

Either add in Travis web UI:
Go to https://travis-ci.com/{organisation}/{repo}/settings and scroll down to Environment Variables. Add PYPI_TOKEN:
Travis Environtment Variables

Or use an encrypted secret inside `.travis.yml
https://docs.travis-ci.com/user/environment-variables#defining-encrypted-variables-in-travisyml

There's an ongoing discussion on jupyterhub/team-compass#213 (comment) about pypi accounts and token scopes, but if you're ready to release might as well use your own token and update later?

@consideRatio
Copy link
Member

Important insights:

  1. Tag builds, which are triggered by a refs/tags/ object in git is pushed, does not belong to a branch. That makes sense, as a tag is a tagged commit, but this can be part of multiple branches or none at all.
  2. If we limit an env var to to a certain branch, that means we exclude tagged builds as they are not part of any branch. It is not possible in the TravisCI web settings to declare if they should be part of tagged builds but not branch builds.
  3. With travis encrypt we could get a nice entry in TravisCI relating to an encrypted environment variable that would allow us to specifically make the PYPI_PASSWORD environment available when it is needed, on tagged builds. But, we can't use it due to a limiting behavior we experience.

Anyhow, we now have a PYPI_PASSWORD setup, which is making the variable accessible on all pushes to the git repo. It is tied to a deployment token specifically for jupyterhub/oauthenticator. Note that I opted for PYPI_PASSWORD over PYPI_TOKEN as this documentation suggest that: https://docs.travis-ci.com/user/deployment-v2/providers/pypi. You can therefore remove the password: $PYPI_TOKEN fields and instead document that the PYPI_PASSWORD will be set indirectly by the PYPI_PASSWORD environment variable.

It sais that the default distribution is sdist, perhaps it should be bdist_wheel or similar also? I'm super noob about these matters really but I think it is very relevant that we inspect the varioable options for PyPI deployment here: https://docs.travis-ci.com/user/deployment-v2/providers/pypi#known-options

@manics manics changed the title [WIP] Travis: Deploy releases to pypi [MRG] Travis: Deploy releases to pypi Nov 18, 2019
@manics
Copy link
Member Author

manics commented Nov 18, 2019

@consideRatio Done!

@consideRatio consideRatio merged commit 791c3ec into jupyterhub:master Nov 18, 2019
@consideRatio
Copy link
Member

@manics ❤️

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.

4 participants