-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from cuda-networks/BNCASB-2204-build-PyPI-package
Bncasb 2204 build py pi package
- Loading branch information
Showing
6 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.36 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |