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 PyPI Publishing with CircleCI #49

Merged
merged 21 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ workflows:
version: 2
test:
jobs:
- py27
- py27:
filters:
tags:
only: /^v.*/
- publish:
requires:
- py27
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
# TODO: - py37

jobs:
Expand All @@ -30,12 +41,34 @@ jobs:
- save_cache:
paths:
./venv/
key: v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "requirements.txt" }}
key: v1-{{ arch }}-{{ .Environment.CIRCLE_PROJECT }}-{{ checksum "setup.py" }}-{{ checksum "requirements.txt" }}
- run:
name: Pytest
command: |
./venv/bin/pytest -v tests/

publish:
docker:
- image: circleci/python:2.7
steps:
- checkout
- restore_cache:
keys:
- v1-{{ arch }}-{{ .Environment.CIRCLE_PROJECT }}-{{ checksum "setup.py" }}-{{ checksum "requirements.txt" }}
- run:
name: verify git tag vs. version
command: |
python -m venv venv || virtualenv venv
. venv/bin/activate
python setup.py verify
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

- run:
name: create packages
command: |
python setup.py sdist
python setup.py bdist_wheel
- run:
name: upload to pypi
command: |
./venv/bin/twine upload --config .pypirc -r pypi dist/* --password $PYPI_PASSWORD_PROD
# TODO:
# py37:
# <<: *template
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ src/indy/specs/build/vendored/*
# build directories
/build/
/docs/_build/

/dist/
/venv/
# compiled files
*.o
*.a
Expand Down
11 changes: 11 additions & 0 deletions .pypirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[distutils]
index-servers=
pypi
testpypi

[pypi]
username: nerdwallet

[testpypi]
repository: https://test.pypi.org/legacy/
username: nerdwallet
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,11 @@ When creating ``aws_security_group_rule`` ``Resource`` objects you cannot pass `
vpc_id=vpc.id,
...
)

Release Steps
=================
1. Create an issue, check out a branch, and make your code changes.
2. Push to run CircleCI tests.
3. Create Pull Request to Master including VERSION bump.
4. Merge PR after Approval.
5. Add tag like v1.0.0 that matches new version and push.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.1
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
schematics==2.1.0
six==1.12.0
twine==1.13.0
25 changes: 24 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
import os
import sys

from setuptools import find_packages, setup
from setuptools.command.install import install

with open('VERSION') as version_fd:
VERSION = version_fd.read().strip()

with open('README.rst') as readme_fd:
long_description = readme_fd.read()

class VerifyVersionCommand(install):
"""Custom command to verify that the git tag matches our version"""
description = 'verify that the git tag matches our version'

def run(self):
if os.getenv('CIRCLE_TAG') == None:
sys.exit("FAILED: Your CIRCLE_TAG variable appears to be unset. Are you running on CircleCI triggered by tag?")
else:
tag = os.getenv('CIRCLE_TAG')

if tag != "v" + VERSION:
info = "Git tag: {0} does not match the version of this app: {1}".format(
tag, VERSION
)
sys.exit(info)

setup(
name='terraformpy',
version=VERSION,
Expand Down Expand Up @@ -45,5 +65,8 @@
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Pre-processors",
"Topic :: System :: Systems Administration",
]
],
cmdclass={
'verify': VerifyVersionCommand,
}
)