Skip to content

Commit fd0c493

Browse files
authored
Merge pull request #48 from cuda-networks/BNCASB-2204-build-PyPI-package
Bncasb 2204 build py pi package
2 parents 1911786 + 7ebed70 commit fd0c493

File tree

6 files changed

+147
-2
lines changed

6 files changed

+147
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## Django EB SQS - Background Tasks for Amazon SQS
1+
2+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3+
[![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)
4+
5+
# Django EB SQS - Background Tasks for Amazon SQS
26

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

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.36

publish-pypi.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
function log()
6+
{
7+
echo "$(date): $1"
8+
}
9+
10+
function usage()
11+
{
12+
echo "Helper to publish the package to PyPI.
13+
Usage: $0 -p <GITHUB_TAG>
14+
-p <GITHUB_TAG> : Github Tag value, semantic realease format eg: v1.36 or v2.0.7
15+
-h : help
16+
"
17+
exit
18+
}
19+
20+
function publish()
21+
{
22+
23+
log "Installing required dependencies"
24+
pip install -r requirements-pypi.txt
25+
26+
# checkout specific tag version
27+
git checkout tags/"$TAG_PARAM"
28+
29+
# creating the distribution package
30+
rm -rf dist/
31+
python setup.py sdist
32+
python setup.py bdist_wheel
33+
34+
log "Publishing package version/tag: $TAG_PARAM"
35+
twine upload dist/* # add --repository-url https://test.pypi.org/legacy/ to push to TestPyPI
36+
37+
exit
38+
}
39+
40+
# Parse and handle command line options
41+
while getopts ":p:h" OPTION; do
42+
case $OPTION in
43+
p)
44+
TAG_PARAM=$OPTARG
45+
publish
46+
;;
47+
*)
48+
usage
49+
;;
50+
esac
51+
done
52+
53+
# if no args specified
54+
if [ "$#" -ne 1 ]
55+
then
56+
usage
57+
fi

requirements-pypi.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
setuptools>=44.0.0
2+
wheel>=0.33.6
3+
twine>=3.1.1

setup.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,31 @@
22
from setuptools import setup, find_packages
33

44
here = os.path.abspath(os.path.dirname(__file__))
5+
VERSION = open(os.path.join(here, 'VERSION')).read()
56
README = open(os.path.join(here, 'README.md')).read()
67

78
setup(
89
name='django-eb-sqs',
9-
version='1.36',
10+
version=VERSION,
1011
package_dir={'eb_sqs': 'eb_sqs'},
1112
include_package_data=True,
1213
packages=find_packages(),
1314
description='A simple task manager for AWS SQS',
1415
long_description=README,
16+
long_description_content_type="text/markdown",
1517
url='https://github.com/cuda-networks/django-eb-sqs',
1618
install_requires=[
1719
'boto3>=1.9.86',
1820
'Django>=1.10.6',
1921
'requests>=2.10.0',
22+
],
23+
classifiers=[
24+
'Intended Audience :: Developers',
25+
'Programming Language :: Python :: 3.7',
26+
'Programming Language :: Python :: 2.7',
27+
'Topic :: Software Development',
28+
'License :: OSI Approved :: MIT License',
29+
'Operating System :: OS Independent',
30+
'Framework :: Django'
2031
]
2132
)

update-version.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
VERSION_PARAM=${1:-AUTO}
6+
7+
function log()
8+
{
9+
echo "$(date): $1"
10+
}
11+
12+
function usage()
13+
{
14+
echo "Helper to update the package version and commit to GitHub.
15+
Usage: $0 <VERSION_NUMBER>
16+
<VERSION_NUMBER> : Version is usually a semantic release eg 1.20, 1.1.7.
17+
VERSION value is optional, if not passed then an auto version update occurs.
18+
-h : help
19+
"
20+
exit
21+
}
22+
23+
function update()
24+
{
25+
# update codebase
26+
git checkout master
27+
git pull
28+
29+
if [ "$VERSION_PARAM" = "AUTO" ]
30+
then
31+
OLD_VER=$(cat VERSION)
32+
NEW_VER=$(echo "$OLD_VER" + .01 | bc)
33+
else
34+
NEW_VER=$VERSION_PARAM
35+
fi
36+
37+
# bump the version
38+
echo "$NEW_VER" > VERSION
39+
log "Version bumped to $NEW_VER"
40+
41+
# push VERSION file and new TAG to git
42+
log "Pushing to GitHub..."
43+
git add VERSION
44+
git commit -a -m "Bump the version to $NEW_VER"
45+
git push
46+
47+
# adding tag
48+
log "Adding Tag..."
49+
TAG="v$NEW_VER"
50+
log "New tag : $TAG"
51+
git tag -a "$TAG" -m "Bumped the version to $NEW_VER"
52+
git push origin "$TAG"
53+
54+
exit
55+
}
56+
57+
# Parse and handle command line options
58+
while getopts ":h" OPTION; do
59+
case $OPTION in
60+
h)
61+
usage
62+
;;
63+
*)
64+
usage
65+
;;
66+
esac
67+
done
68+
69+
update

0 commit comments

Comments
 (0)