Skip to content

Commit

Permalink
Refactored circleci config, updated bumpversion config to match semver
Browse files Browse the repository at this point in the history
  • Loading branch information
ravenoak committed Apr 18, 2019
1 parent 7919b34 commit 3cca81c
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 54 deletions.
171 changes: 122 additions & 49 deletions .circleci/config.yml
@@ -1,16 +1,87 @@
version: 2.1

commands:

bumpversion:
description: "Uses bump2version to increase version number"
parameters:
version_part:
type: enum
enum: ['major', 'minor', 'patch', 'pre_release', 'pre_release_num', 'dev_num']
bump_options:
type: string
default: '--no-tag --commit -m "Bump version: {current_version} → {new_version} [ci skip]"'
steps:
- restore_cache:
key: v1-bumpversion
- run:
name: Install/Upgrade bumpversion
command: |
python3 -m venv venv
. venv/bin/activate
pip3 install -U bump2version
- save_cache:
key: v1-bumpversion
paths:
- "venv"
- run:
name: Bumpversion dev
command: |
git config --global user.email "git-robot@virtualxistenz.com"
git config --global user.name "Git Robot"
. venv/bin/activate
python3 setup.py --version
bumpversion << parameters.bump_options >> << parameters.version_part >>
python3 setup.py --version
git log -n 1
- run:
name: Push version bump
command: |
git push -u origin $CIRCLE_BRANCH
publish:
description: "Uses twine to publish packages to PyPI"
steps:
- restore_cache:
keys:
- v1-release-{{ .Branch }}-{{ checksum "requirements.txt" }}
- v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}-py37
- run:
name: Install/Upgrade release requirements
command: |
python3 -m venv venv
. venv/bin/activate
pip3 install -U -r requirements.txt
pip3 install -U twine
- save_cache:
key: v1-release-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "venv"
- run:
name: Verify git tag vs. package version
command: |
. venv/bin/activate
python setup.py verify
- run:
name: Publish to Prod PyPI
command: |
. venv/bin/activate
python3 setup.py sdist
python3 setup.py bdist_wheel
twine upload dist/*
jobs:

deps_py37:
install_deps_py37:
docker:
- image: circleci/python:3.7
steps:
- checkout
- restore_cache:
key: v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}
- run:
name: Install python dependencies
name: Install package dependencies
command: |
python3 -m venv venv
. venv/bin/activate
Expand All @@ -20,7 +91,7 @@ jobs:
paths:
- "venv"

test_py37:
unittest_py37:
docker:
- image: circleci/python:3.7
environment:
Expand All @@ -45,72 +116,74 @@ jobs:
python3 --version
python3 setup.py install
bump_release_dev:
bump_publish_dev:
docker:
- image: circleci/python:3.7
environment:
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
steps:
- add_ssh_keys:
fingerprints:
- "04:9e:4c:45:49:63:80:3b:5c:b4:ee:9e:36:5c:2a:ea"
- checkout
- restore_cache:
keys:
- v1-release-{{ .Branch }}-{{ checksum "requirements.txt" }}
- v1-dependency-cache-{{ .Branch }}-{{ checksum "requirements.txt" }}-py37
- run:
name: Install/Upgrade release requirements
command: |
python3 -m venv venv
. venv/bin/activate
pip3 install -U -r requirements.txt
pip3 install -U bump2version twine
- save_cache:
key: v1-release-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "venv"
- run:
name: Bumpversion dev
command: |
git config --global user.email "git-robot@virtualxistenz.com"
git config --global user.name "Git Robot"
. venv/bin/activate
python3 setup.py --version
bumpversion --commit -m "Bump version: {current_version} → {new_version} [ci skip]" --no-tag dev_num
python3 setup.py --version
git log -n 1
- run:
name: Push version bump
command: |
git push -u origin develop
- run:
name: Publish to Test PyPI
command: |
. venv/bin/activate
export TWINE_USERNAME=$TEST_PYPI_USERNAME
export TWINE_PASSWORD=$TEST_PYPI_PASSWORD
python3 setup.py sdist
python3 setup.py bdist_wheel
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
- bumpversion:
version_part: dev_num
- publish

bump_publish_release:
docker:
- image: circleci/python:3.7
steps:
- add_ssh_keys:
fingerprints:
- "04:9e:4c:45:49:63:80:3b:5c:b4:ee:9e:36:5c:2a:ea"
- checkout
- bumpversion:
version_part: pre_release_num
- publish

publish_prod_tag:
docker:
- image: circleci/python:3.7
steps:
- checkout
- publish

workflows:
version: 2

build_test_release_py37:
build_test_publish_py37:
jobs:
- deps_py37:
- install_deps_py37:
filters:
tags:
only: /.*/
- test_py37:
- unittest_py37:
requires:
- deps_py37
- install_deps_py37
filters:
tags:
only: /.*/
- bump_release_dev:
context: PyPI
- bump_publish_dev:
context: Test PyPI
requires:
- test_py37
- unittest_py37
filters:
branches:
only: develop
- bump_publish_release:
context: Prod PyPI
requires:
- unittest_py37
filters:
branches:
only: /^release\//
- publish_prod_tag:
context: Prod PyPI
requires:
- unittest_py37
filters:
tags:
only: /^v[0-9]+(\.[0-9]+)+$/
branches:
ignore: /.*/
10 changes: 5 additions & 5 deletions setup.cfg
@@ -1,11 +1,11 @@
[bumpversion]
current_version = 0.1.0.dev5
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<micro>\d+)((?P<pre_release>a|b|rc)(?P<pre_release_num>\d+))?(\.dev(?P<dev_num>\d+))?
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<pre_release>a|b|rc)(?P<pre_release_num>\d+))?(\.dev(?P<dev_num>\d+))?
serialize =
{major}.{minor}.{micro}{pre_release}{pre_release_num}.dev{dev_num}
{major}.{minor}.{micro}.dev{dev_num}
{major}.{minor}.{micro}{pre_release}{pre_release_num}
{major}.{minor}.{micro}
{major}.{minor}.{patch}{pre_release}{pre_release_num}.dev{dev_num}
{major}.{minor}.{patch}.dev{dev_num}
{major}.{minor}.{patch}{pre_release}{pre_release_num}
{major}.{minor}.{patch}

[metadata]
author = Caitlyn O'Hanna
Expand Down

0 comments on commit 3cca81c

Please sign in to comment.