-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
- I have searched the issues of this repo and believe that this is not a duplicate.
- I have searched the documentation and believe that my question is not covered.
Question
Hi! I've been working with poetry
recently and am happy that I can publish packages to pypi or my own hosted package repository with it. I would like to share my current setup with TravisCI in hopes that it could help others. I would also like to learn from those who have more experience with poetry
to get tips on how I might make this setup better, or see how it works with other continuous integration platforms, or other more in depth CI/CD requirements.
My requirements for travis-ci are fairly common.
- Use
poetry
to install my project dependencies and dev dependencies. - Run lint and unit tests for my project.
- When the project is git tagged, to build and publish my project to my companies internal pypi registry.
.travis.yml
language: python
python:
- 3.6
env:
global:
- secure: "<encrypted MYPYPI_USER=username>"
- secure: "<encrypted MYPYPI_PASS=p@ssword>"
before_install:
- pip install poetry
install:
- poetry install
script:
- poetry run flake8 my_package test
- poetry run coverage run --source=my_package -m unittest discover -b
before_deploy:
- poetry config repositories.mypypi http://mypypi.example.com/simple
- poetry config http-basic.mypypi $MYPYPI_USER $MYPYPI_PASS
- poetry build -f sdist
deploy:
provider: script
script: poetry publish -r mypypi
skip_cleanup: true
on:
tags: true
I have in the past used the built in travis pypi deployment, but it requires a setup.py
( which I don't have anymore! 🙌). So instead I'm running my poetry publish as a script deployment when I tag my repo.
So when master is at a spot where I want to deploy a new version of the package. I do something like.
poetry version minor
git commit -am 'bumped the version'
git tag <version>
# SIDE NOTE: it would be nice to be able to do `git tag $(poetry version --show)`
# or possibly have the bump command output the NEW_VERSION=poetry version minor --output
git push --tags
In order to configure poetry with the credentials to push to our repository I have set $MYPYPI_USER
and $MYPYPI_PASS
encrypted environment variables in travis.
That's what I have. Cheers 🍺