Skip to content

Commit

Permalink
Merge pull request #48 from cuda-networks/BNCASB-2204-build-PyPI-package
Browse files Browse the repository at this point in the history
Bncasb 2204 build py pi package
  • Loading branch information
rohandev authored Jan 20, 2020
2 parents 1911786 + 7ebed70 commit fd0c493
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Django EB SQS - Background Tasks for Amazon SQS

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CircleCI](https://img.shields.io/circleci/build/github/cuda-networks/django-eb-sqs/master)](https://circleci.com/gh/cuda-networks/django-eb-sqs/tree/master)

# Django EB SQS - Background Tasks for Amazon SQS

django-eb-sqs is a simple task manager for AWS SQS. It uses SQS and the [boto3](https://github.com/boto/boto3) library.

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.36
57 changes: 57 additions & 0 deletions publish-pypi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

set -e

function log()
{
echo "$(date): $1"
}

function usage()
{
echo "Helper to publish the package to PyPI.
Usage: $0 -p <GITHUB_TAG>
-p <GITHUB_TAG> : Github Tag value, semantic realease format eg: v1.36 or v2.0.7
-h : help
"
exit
}

function publish()
{

log "Installing required dependencies"
pip install -r requirements-pypi.txt

# checkout specific tag version
git checkout tags/"$TAG_PARAM"

# creating the distribution package
rm -rf dist/
python setup.py sdist
python setup.py bdist_wheel

log "Publishing package version/tag: $TAG_PARAM"
twine upload dist/* # add --repository-url https://test.pypi.org/legacy/ to push to TestPyPI

exit
}

# Parse and handle command line options
while getopts ":p:h" OPTION; do
case $OPTION in
p)
TAG_PARAM=$OPTARG
publish
;;
*)
usage
;;
esac
done

# if no args specified
if [ "$#" -ne 1 ]
then
usage
fi
3 changes: 3 additions & 0 deletions requirements-pypi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setuptools>=44.0.0
wheel>=0.33.6
twine>=3.1.1
13 changes: 12 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@
from setuptools import setup, find_packages

here = os.path.abspath(os.path.dirname(__file__))
VERSION = open(os.path.join(here, 'VERSION')).read()
README = open(os.path.join(here, 'README.md')).read()

setup(
name='django-eb-sqs',
version='1.36',
version=VERSION,
package_dir={'eb_sqs': 'eb_sqs'},
include_package_data=True,
packages=find_packages(),
description='A simple task manager for AWS SQS',
long_description=README,
long_description_content_type="text/markdown",
url='https://github.com/cuda-networks/django-eb-sqs',
install_requires=[
'boto3>=1.9.86',
'Django>=1.10.6',
'requests>=2.10.0',
],
classifiers=[
'Intended Audience :: Developers',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 2.7',
'Topic :: Software Development',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Framework :: Django'
]
)
69 changes: 69 additions & 0 deletions update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

set -e

VERSION_PARAM=${1:-AUTO}

function log()
{
echo "$(date): $1"
}

function usage()
{
echo "Helper to update the package version and commit to GitHub.
Usage: $0 <VERSION_NUMBER>
<VERSION_NUMBER> : Version is usually a semantic release eg 1.20, 1.1.7.
VERSION value is optional, if not passed then an auto version update occurs.
-h : help
"
exit
}

function update()
{
# update codebase
git checkout master
git pull

if [ "$VERSION_PARAM" = "AUTO" ]
then
OLD_VER=$(cat VERSION)
NEW_VER=$(echo "$OLD_VER" + .01 | bc)
else
NEW_VER=$VERSION_PARAM
fi

# bump the version
echo "$NEW_VER" > VERSION
log "Version bumped to $NEW_VER"

# push VERSION file and new TAG to git
log "Pushing to GitHub..."
git add VERSION
git commit -a -m "Bump the version to $NEW_VER"
git push

# adding tag
log "Adding Tag..."
TAG="v$NEW_VER"
log "New tag : $TAG"
git tag -a "$TAG" -m "Bumped the version to $NEW_VER"
git push origin "$TAG"

exit
}

# Parse and handle command line options
while getopts ":h" OPTION; do
case $OPTION in
h)
usage
;;
*)
usage
;;
esac
done

update

0 comments on commit fd0c493

Please sign in to comment.