Skip to content

Commit c84132c

Browse files
committed
add cicd build
1 parent 203e407 commit c84132c

File tree

5 files changed

+125
-0
lines changed

5 files changed

+125
-0
lines changed

.dockerignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.pytest_cache/
2+
build/
3+
coverage/
4+
dist/
5+
pybbn.egg-info/
6+
docs/build/
7+
.coverage
8+
.noseids
9+
.ipynb_checkpoints/
10+
joblib_memmap/

Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM oneoffcoder/python-java:latest
2+
3+
LABEL author="Jee Vang, Ph.D."
4+
LABEL email="[email protected]"
5+
6+
ARG ALIB_VERSION
7+
ARG APYPI_REPO
8+
9+
ENV LIB_VERSION=$ALIB_VERSION
10+
ENV PYPI_REPO=$APYPI_REPO
11+
12+
RUN apt-get update \
13+
&& apt-get upgrade -y \
14+
&& DEBIAN_FRONTEND=noninteractive apt-get install graphviz libgraphviz-dev pkg-config -y
15+
COPY . /pypi-lib
16+
RUN pip install -r /pypi-lib/requirements.txt
17+
RUN /pypi-lib/publish.sh

build.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
DOCKER_FILE=Dockerfile
4+
DOCKER_REPO=lassobbn
5+
DOCKER_TAG=local
6+
ALIB_VERSION=version
7+
APYPI_REPO=repo
8+
9+
while getopts v:r: option
10+
do
11+
case "${option}"
12+
in
13+
v) ALIB_VERSION=${OPTARG};;
14+
r) APYPI_REPO=${OPTARG};;
15+
esac
16+
done
17+
18+
if [[ "version" == ALIB_VERSION || "repo" == $APYPI_REPO ]]; then
19+
echo "Usage: ./build.sh -r [pypi|testpypi] -v [version]"
20+
echo " -r repository, pypi or testpypi"
21+
echo " -v version e.g. 0.2.5"
22+
else
23+
docker build --no-cache \
24+
-f $DOCKER_FILE \
25+
--build-arg ALIB_VERSION=$ALIB_VERSION \
26+
--build-arg APYPI_REPO=$APYPI_REPO \
27+
-t ${DOCKER_REPO}:${DOCKER_TAG} .
28+
fi

publish.sh

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
SOURCE_DIST=/py-bbn/dist/pybbn-${LIB_VERSION}.tar.gz
4+
5+
buildCode() {
6+
echo "start the build"
7+
cd /pypi-lib \
8+
&& make clean \
9+
&& make \
10+
&& python setup.py sdist bdist bdist_wheel \
11+
&& twine check dist/* \
12+
&& cd /pypi-lib/docs \
13+
&& make html
14+
}
15+
16+
updateVersion() {
17+
echo "replace version of software to ${LIB_VERSION}"
18+
sed -i "s/version='0.0.1'/version='${LIB_VERSION}'/g" /pypi-lib/setup.py
19+
}
20+
21+
copyCredentials() {
22+
if [[ -f /pypi-lib/.pypirc ]]; then
23+
echo "copying over .pypirc"
24+
cp /pypi-lib/.pypirc /root/.pypirc
25+
fi
26+
}
27+
28+
publish() {
29+
echo "python publish"
30+
31+
if [[ -f /root/.pypirc ]]; then
32+
if [[ -f ${SOURCE_DIST} ]]; then
33+
echo "uploading source"
34+
cd /pypi-lib \
35+
&& make clean \
36+
&& python setup.py sdist \
37+
&& twine upload --repository ${PYPI_REPO} ${SOURCE_DIST}
38+
else
39+
echo "no ${SOURCE_DIST} found!"
40+
fi
41+
else
42+
echo "no .pypirc found!"
43+
fi
44+
}
45+
46+
cleanUp() {
47+
if [[ -f /root/.pypirc ]]; then
48+
echo "cleaning up"
49+
rm -f /root/.pypirc
50+
fi
51+
}
52+
53+
build() {
54+
echo "python build"
55+
buildCode
56+
publish
57+
}
58+
59+
conda init bash
60+
. /root/.bashrc
61+
updateVersion
62+
copyCredentials
63+
build
64+
cleanUp
65+
66+
echo "done!"

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ pybbn
1414
# DOCUMENTATION
1515
sphinx
1616
sphinx_rtd_theme
17+
sphinxcontrib-bibtex
18+
sphinxcontrib-blockdiag
19+
sphinx-sitemap
20+
nbsphinx
1721
# PUBLISHING
1822
twine

0 commit comments

Comments
 (0)