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

👷📦🚀 Enable Travis CI to publish dists to PYPI #262

Merged
merged 15 commits into from
Aug 4, 2018

Conversation

webknjaz
Copy link
Contributor

@webknjaz webknjaz commented Jun 10, 2018

Resolves #222

@Mariatta you still need to update secret and probably add @brettcannon's account for blurb.

Some hacks present are trying to work around limitations described in travis-ci/dpl#822

.travis.yml Outdated
# This happenes when other CI (AppVeyor etc.) has already uploaded
# the very same dist (usually sdist).
skip-existing: true
user: Mariatta # TODO: consider having a separate "uploader user"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Mariatta you might want to set up a separate account with "Maintainer" level privileges in PYPI to use instead of your own, which is more dangerous if it gets compomised.

Recently, we've started replacing our flows to use a deployment-dedicated user in aio-libs as well: https://github.com/aio-libs/aiohttp/blob/master/.travis.yml#L84

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Mariatta I've just realized that blurb is deployed by @brettcannon and your account is not linked to that dist. Will you fix this by having an account with access to publish both or should I separate deployment step to have different deployer users?

.travis.yml Outdated
# Encrypt with `travis encrypt -r python/core-workflow --org` while using travis-ci.org;
# change to `travis encrypt -r python/core-workflow --api-endpoint 'https://api.travis-ci.com/'`
# upon switch to __free__ travis-ci.com:
secure: PLACE_YOUR_ENCRYPTED_PASSWORD_HERE
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Mariatta feel free to update the PR branch with a secret generated for your account as per instructions in comments above.

@webknjaz webknjaz force-pushed the feature/travis-cd-to-pypi branch 4 times, most recently from 076f934 to 91b4aab Compare June 11, 2018 11:49
@webknjaz
Copy link
Contributor Author

@Mariatta I've fixed conditionals.

Demo:

It should be ready for merging (you may add PYPI creds before or after merge).

@webknjaz
Copy link
Contributor Author

webknjaz commented Jun 22, 2018

@Mariatta I'm going to update this to exclude non-related builds when releasing a certain tool. This will include conditions: v1 and moving stuff off the matrix to explicit jobs.include.

Ref: travis-ci/travis-conditions#1

@Mariatta
Copy link
Member

Mariatta commented Jul 9, 2018

tag cherry-picker-v1.2.19: https://travis-ci.com/webknjaz/core-workflow/builds/75899965

That build failed. Any clue?

Just to confirm how this will work, when I'm ready to release to PyPI, just create a tag like cherry-picker-vX.Y.Z and travis will run?

@webknjaz
Copy link
Contributor Author

@Mariatta oh it's fine.

HTTPError: 403 Client Error: Invalid or non-existent authentication information. for url: https://upload.pypi.org/legacy/

I didn't put any valid PYPI credentials there. That's why this happened. It will work once you add credentials as per https://github.com/python/core-workflow/pull/262/files#diff-354f30a63fb0907d4ad57269548329e3R54.
(You can push those to my branch bound to this PR via UI or Git)

@webknjaz
Copy link
Contributor Author

@Mariatta I've made jobs appearence more granular for release mode.

@webknjaz
Copy link
Contributor Author

@Mariatta just in case it gets lost in diff page, we need to solve this as well: #262 (comment)

@webknjaz
Copy link
Contributor Author

@Mariatta do you need any additional help with this?

@Mariatta
Copy link
Member

Mariatta commented Aug 1, 2018

@webknjaz I've asked @brettcannon to create the bot account for deployment to PyPI. Not sure if he's gotten around doing it yet.

@webknjaz
Copy link
Contributor Author

webknjaz commented Aug 1, 2018

@Mariatta alternatively you could create a shared acc yourself and then you can add it to one project with minimal privileges and @brettcannon would add it to other. If this helps :)

@brettcannon
Copy link
Member

I just created the core-workflow account.

@brettcannon
Copy link
Member

https://pypi.org/user/core-workflow/

.travis.yml Outdated
# Encrypt with `travis encrypt -r python/core-workflow --org` while using travis-ci.org;
# change to `travis encrypt -r python/core-workflow --api-endpoint 'https://api.travis-ci.com/'`
# upon switch to __free__ travis-ci.com:
secure: PLACE_YOUR_ENCRYPTED_PASSWORD_HERE
Copy link
Member

Choose a reason for hiding this comment

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

Thanks @brettcannon for creating the core-workflow PyPI user. I've added it as maintainer to cherry_picker in PyPI.
Do you mind creating the encrypted password and add it here?

Copy link
Member

Choose a reason for hiding this comment

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

Sent the password to Mariatta securely as I'm heading out for a short vacation once I'm done with my GitHub notifications 😄

.travis.yml Outdated
# This happenes when other CI (AppVeyor etc.) has already uploaded
# the very same dist (usually sdist).
skip-existing: true
user: &pypi-user Mariatta # TODO: consider having a separate "uploader user"
Copy link
Member

Choose a reason for hiding this comment

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

This has to be core-workflow now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

May I expect that you will update this branch yourself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If not - please share the encrypted string and I'll do it myself :)

Copy link
Member

Choose a reason for hiding this comment

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

I've updated. At least I think I did it correctly ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks fine. Sometimes it doesn't work because of corrupted secret value, but we'll only see this during actual deployment in this repo. Re-encryption usually helps.

.travis.yml Outdated
env:
TARGET_PKG: blurb
deploy:
<<: *deployment-config
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if blurb maintainers (I'm not one of them) want the same capability or not. Maybe we need to remove this portion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really like removing stuff. Instead, we can add smth likeif: false to disable this. Deal?

Copy link
Member

Choose a reason for hiding this comment

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

Ok :)

- &run-if-tagged
if: tag IS present
- &run-if-cherry-picker
if: tag =~ ^cherry\-picker\-v\d+\.\d+\.\d+$
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Mariatta I'm a bit concerned about restricting this to vX.Y.Z format, while in real life there might be some extensions (dev/a/b). Should I extend this regexp to take those into account?

Copy link
Member

Choose a reason for hiding this comment

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

I think we can leave the regex as is (handling vX.Y.Z) and when the need arise we can adjust it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I just thought of a common use case for testing pre-releases when you are unsure whether build artifact (dist) is correct.

@webknjaz
Copy link
Contributor Author

webknjaz commented Aug 4, 2018

I believe that you can merge this now.

@webknjaz
Copy link
Contributor Author

webknjaz commented Aug 4, 2018

I would then test releasing mechanizm, but since it's a change, which does not affect the software, I'd add .post0. It looks like a right thing to do.

Copy link
Member

@Mariatta Mariatta left a comment

Choose a reason for hiding this comment

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

Thanks!!! 🌮

@Mariatta Mariatta merged commit 084b51e into python:master Aug 4, 2018
@Mariatta
Copy link
Member

Mariatta commented Aug 4, 2018

Once we have updated changelog for cherry_picker (open issue #279), I can try to cut a release. But I'm about to head to the beach now 🏖 ...

@webknjaz
Copy link
Contributor Author

webknjaz commented Aug 4, 2018

🎉

@webknjaz
Copy link
Contributor Author

webknjaz commented Aug 4, 2018

Yeah, actually me too: just arrived to Cyprus a few hours ago 🌴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants