...
CircleCI vs Jenkins
will it be a separate CircleCI job or part of an existing workflow
publish to a test server first (ie. local PyPI server) before publishing to the production PyPI server
Auto-releasing packages with CircleCI
the following workflow, build-and-deploy
, will be triggered when a new tag/release is created on GitHub
build-and-deploy
workflow is composed of 2 jobs:
build
installs
pytest
and installs the python package locallyruns
pytest
publish-pypi
(only if the previousbuild
job completes)initializes the
.pypirc
file with the URL, credentials, etc. for publishingpip install twine
builds the python package distribution
publishes to PyPI with
twine
CircleCI’s config.yml
:
Code Block | ||
---|---|---|
| ||
version: 2.1
jobs:
build:
docker:
- image: circleci/python:3.9
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
steps:
- checkout
- run:
name: Install dependencies
command: |
pip install pytest==7.2.0
pip install .
- run:
name: pytest
command: |
pytest .
publish-pypi:
docker:
- image: circleci/python:3.9
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
steps:
- checkout
- run:
name: Init .pypirc
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "repository: https://upload.pypi.org/legacy/" >> ~/.pypirc
echo -e "username: $PYPI_USER" >> ~/.pypirc
echo -e "password: $PYPI_PASSWORD" >> ~/.pypirc
- run:
name: Install tools
command: |
pip install twine==4.0.2
- run:
name: Install and publish to PyPI
command: |
pip install .
python setup.py sdist bdist_wheel
twine upload dist/* --verbose --config-file ~/.pypirc
workflows:
version: 2
build-and-deploy:
jobs:
- build:
context:
- docker-hub-creds
- git-oauth-token
- pypi-creds
- publish-pypi:
context:
- docker-hub-creds
- git-oauth-token
requires:
- build
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/ |
To-do list:
- Publish HySDS packages to PyPI test server (
prov_es
,osaka
,hysds_commons
,hysds
) - Publish HySDS packages to PyPI’s official server
- Integrate CircleCI to build and publish to PyPI whenever we make a new release
- Publish HySDS to conda (optional)