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

Auto deploys to PyPI using Travis on tags #2122

Merged
merged 1 commit into from
Apr 7, 2020

Conversation

AndreMiras
Copy link
Member

Uses PyPI __token__ and Travis auto deployment to publish to PyPI
upon tagging.
https://pypi.org/help/#apitoken
Travis uses the not so well documented PYPI_PASSWORD environment
variable to store the password.
https://github.com/travis-ci/dpl/blob/v1.10.15/lib/dpl/provider/pypi.rb#L12
The variable was set with a valid token prior this change.
https://travis-ci.org/github/kivy/python-for-android/settings
This is more secure than user and password as tokens are generated with
uploaded only permissions and can be scoped to a given project.

@AndreMiras
Copy link
Member Author

AndreMiras commented Apr 1, 2020

Prior to this change, I made a test setting a version already deployed (__version__ = '2019.10.06') in pythonforandroid/__init__.py to check if PyPI deployment would conflict and it was the case, see https://travis-ci.org/github/kivy/python-for-android/jobs/669898576

...
Uploading distributions to https://upload.pypi.org/legacy/
Uploading python_for_android-2019.10.6-py3-none-any.whl
100% 574k/574k [00:00<00:00, 1.34MB/s] 
NOTE: Try --verbose to see response content.
HTTPError: 400 Client Error: File already exists. See https://pypi.org/help/#file-name-reuse for url: https://upload.pypi.org/legacy/
...

I also temporarily changed the tags: true to all_branches: true in order to have the deployment happen during my trial.
All this helped validate the credentials are properly setup to perform auto deployments using Travis.
I then reverted/squashed the change to this PR, ready to be merged

@AndreMiras
Copy link
Member Author

Build fail with openssl download issue:

  File "/home/user/app/pythonforandroid/toolchain.py", line 154, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/user/app/pythonforandroid/toolchain.py", line 208, in build_dist_from_args
    args, "ignore_setup_py", False
  File "/home/user/app/pythonforandroid/build.py", line 553, in build_recipes
    recipe.download_if_necessary()
  File "/home/user/app/pythonforandroid/recipe.py", line 347, in download_if_necessary
    self.download()
  File "/home/user/app/pythonforandroid/recipe.py", line 393, in download
    self.download_file(self.versioned_url, filename)
  File "/home/user/app/pythonforandroid/recipe.py", line 208, in download_file
    urlretrieve(url, target, report_hook)
  File "/usr/lib/python3.6/urllib/request.py", line 1819, in retrieve
    block = fp.read(bs)
  File "/home/user/app/venv/lib/python3.6/tempfile.py", line 624, in func_wrapper
    return func(*args, **kwargs)
ValueError: read of closed file
make: *** [testapps-with-numpy/arm64-v8a] Error 1
- Download 0.00%
Makefile:39: recipe for target 'testapps-with-numpy/arm64-v8a' failed
Makefile:77: recipe for target 'docker/run/make/with-artifact/testapps-with-numpy/arm64-v8a' failed
make: *** [docker/run/make/with-artifact/testapps-with-numpy/arm64-v8a] Error 2

I will rebase to #2121 once it's merged to develop

Uses PyPI `__token__` and Travis auto deployment to publish to PyPI
upon tagging.
https://pypi.org/help/#apitoken
Travis uses the not so well documented `PYPI_PASSWORD` environment
variable to store the password.
https://github.com/travis-ci/dpl/blob/v1.10.15/lib/dpl/provider/pypi.rb#L12
The variable was set with a valid token prior this change.
https://travis-ci.org/github/kivy/python-for-android/settings
This is more secure than user and password as tokens are generated with
uploaded only permissions and can be scoped to a given project.
@AndreMiras AndreMiras force-pushed the feature/auto_release_pypi branch from 8e079af to 266cfc3 Compare April 1, 2020 22:08
@AndreMiras AndreMiras requested a review from opacam April 7, 2020 06:09
Copy link
Member

@opacam opacam left a comment

Choose a reason for hiding this comment

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

Nice PR!! 👍

Just wondering, why not do this with github actions?
I know, that travis it has been around for a while, and is pretty well tested, but one great thing about github actions, is that you can split the logic into multiple files, so in a long term, I think is more maintainable. Is it possible to do similar thing with travis?

@AndreMiras
Copy link
Member Author

Thanks for the review! Yes that's basically it for Travis, the setup was easy and I got it working in the past, so it was slightly less headaches. Also one thing I'm really missing with github action is being able to restart just one job rather than the full workflow.
Still I definitely agree in the long run splitting into different files make things more maintainable

@opacam
Copy link
Member

opacam commented Apr 7, 2020

Yes, you are right, restart all the jobs is not ideal, but with a separate workflow for the publish thing, a separate job it will be created, so you shouldn't have to restart all jobs...anyway, we could move that to github actions later. So I have no problem on merging this 😉

@AndreMiras AndreMiras merged commit 8670de6 into develop Apr 7, 2020
@AndreMiras AndreMiras deleted the feature/auto_release_pypi branch April 7, 2020 09:58
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