Skip to content

Commit

Permalink
Fixes #28 (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashnair1 authored Mar 14, 2021
1 parent a2ed917 commit ba975d2
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 4 deletions.
88 changes: 88 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,70 @@ jobs:
- store_artifacts:
path: coverage

test_deploy:
working_directory: ~/project
docker:
- image: circleci/python:3.6.6
steps:
- checkout
- run:
name: Setup environment
command: |
sudo chown -R circleci:circleci /usr/local/
python -m pip install --upgrade pip
python -m pip install twine
- run:
name: Verify git tag vs version
command: |
python setup.py verify
- run:
name: Init .pypirc
command: |
echo -e "[testpypi]" >> ~/.pypirc
echo -e "repository: https://test.pypi.org/legacy/" >> ~/.pypirc
echo -e "username = ashnair1" >> ~/.pypirc
echo -e "password = $TEST_PYPI_PASSWORD" >> ~/.pypirc
- run:
name: Build and upload to Test PyPI
command: |
python setup.py sdist bdist_wheel
twine upload --repository testpypi dist/*
deploy:
working_directory: ~/project
docker:
- image: circleci/python:3.6.6
steps:
- checkout
- run:
name: Setup environment
command: |
sudo chown -R circleci:circleci /usr/local/
python -m pip install --upgrade pip
python -m pip install twine
- run:
name: Verify git tag vs version
command: |
python setup.py verify
- run:
name: Init .pypirc
command: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = ashnair1" >> ~/.pypirc
echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc
- run:
name: Build and upload to PyPI
command: |
python setup.py sdist bdist_wheel
twine upload dist/*
workflows:
version: 2.1
Expand All @@ -48,4 +112,28 @@ workflows:
only:
- master
- dev
build_deploy:
jobs:
- test_coco_assistant:
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
- test_deploy:
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
- deploy:
requires:
- test_coco_assistant
- test_deploy
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/


2 changes: 1 addition & 1 deletion coco_assistant/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.1
0.3.3
24 changes: 21 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import io
import os
import sys
from pathlib import Path

from setuptools import find_packages, setup

from setuptools.command.install import install

# Package meta-data.
NAME = "coco_assistant"
Expand Down Expand Up @@ -49,17 +50,31 @@ def list_reqs(fname="requirements.txt"):
return required, dependency_links


here = os.path.abspath(os.path.dirname(__file__))
here = Path(__file__).cwd()

# Import the README and use it as the long-description.
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
try:
with io.open(os.path.join(here, "README.md"), encoding="utf-8") as f:
with io.open(here / Path("README.md"), encoding="utf-8") as f:
long_description = "\n" + f.read()
except OSError:
long_description = DESCRIPTION


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):
tag = os.getenv("CIRCLE_TAG")
VERSION = about["__version__"]

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


# Load the package's __version__.py module as a dictionary.
ROOT_DIR = Path(__file__).resolve().parent
PACKAGE_DIR = ROOT_DIR / NAME
Expand Down Expand Up @@ -99,4 +114,7 @@ def list_reqs(fname="requirements.txt"):
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
cmdclass={
"verify": VerifyVersionCommand,
},
)

0 comments on commit ba975d2

Please sign in to comment.