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
Merged
96 changes: 82 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,106 @@
conditions: v1

language: python
python:
- "3.5"
- "3.6-dev"
- "3.7-dev"
- "nightly"

dist: trusty
sudo: false
cache: pip

before_install:
- pip install --upgrade flit
install:
- pushd blurb
- flit install
- popd
script:
- blurb test

.mixtures:
- &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.

- &run-if-blurb
if: tag =~ ^blurb\-v\d+\.\d+\.\d+$
- &run-if-cherry-picker-or-untagged
if: tag IS NOT present OR tag =~ ^cherry\-picker\-v\d+\.\d+\.\d+$
- &run-if-blurb-or-untagged
if: tag IS NOT present OR tag =~ ^blurb\-v\d+\.\d+\.\d+$
- &install-and-test-cherry-picker
<<: *run-if-cherry-picker-or-untagged
env:
TARGET_PKG: cherry_picker
install:
- pushd cherry_picker
- &cd-to-project pushd "$TARGET_PKG"
- flit install
- popd
script:
- pushd cherry_picker
- pytest cherry_picker/test.py -v
- popd
- &install-and-test-blurb
<<: *run-if-blurb-or-untagged
env:
TARGET_PKG: blurb
install:
- *cd-to-project
- flit install
- popd
script:
- blurb test
- &deploy-base
stage: Publish dists to PYPI
<<: *run-if-tagged
python: "3.6-dev"
install:
- *cd-to-project
script:
- flit build
before_deploy:
# Add an empty setup.py stub, because pypi provider always calls it
- touch setup.py
deploy: &deployment-config
provider: pypi
# `skip-cleanup: true` is required to preserve binary wheel and sdist,
# built by during `install` step above.
skip-cleanup: true
# `skip-existing: true` is required to skip uploading dists, already
# present in PYPI instead of failing the whole process.
# 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.

# with reduced priviliges for security reasons
password: &pypi-password
# 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.

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 😄

on:
tags: true
all_branches: true

jobs:
include:
- python: "3.5"
<<: *install-and-test-blurb
- python: "3.6-dev"
<<: *install-and-test-blurb
- python: "3.7-dev"
<<: *install-and-test-blurb
- python: "nightly"
<<: *install-and-test-blurb

- python: "3.6-dev"
<<: *install-and-test-cherry-picker
- python: "3.7-dev"
<<: *install-and-test-cherry-picker
- python: "nightly"
<<: *install-and-test-cherry-picker

- <<: *deploy-base
<<: *run-if-cherry-picker
env:
TARGET_PKG: cherry_picker

- <<: *deploy-base
<<: *run-if-blurb
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 :)

user: *pypi-user # TODO: consider having a separate "uploader user"
# with reduced priviliges for security reasons
password: *pypi-password # FIXME: might need to change user/password pair