forked from Azure/iotedgedev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
103 lines (84 loc) · 2.15 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# stop on error
set -e
function show_help
{
echo "Usage:"
echo "build.sh <mode>"
echo ""
echo "mode: test|prod [windows|linux]"
exit 1
}
MODE="$1"
PLATFORM="$2"
if [ -z "$MODE" ]; then
show_help
fi
echo -e "\n===== Setting up build environment"
if [ "$MODE" = "test" ]; then
echo "Environment: $MODE"
elif [ "$MODE" = "prod" ]; then
echo "Environment: $MODE"
else
echo "ERROR> Build mode parameter not known. must be 'prod' or 'test'"
exit 1
fi
if [ ! -z $PLATFORM ]; then
echo "Platform: $PLATFORM"
fi
echo -e "\n===== Checking pre-requisistes"
IS_ADMIN=$(powershell '([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")')
if [ "$IS_ADMIN" = "False" ]; then
echo "ERROR> Build script must be run as administrator"
exit 1
fi
#TODO
# check if running in administrator mode
# make sure docker is in linux mode
# make sure docker supports manifest option
# stop and restart docker to make sure to avoid networking problem?
# check that dockerhub exists and is accessible
# check that pipy repo exists and is accessible
# make sure there are no pending changes in GIT otherwise bumpversion will complain
function run_tox {
echo -e "\n===== Preventive cleanup"
rm __pycache__ -rf
rm .pytest_cache -rf
rm .tox -rf
rm .pytest_cache -rf
rm tests/__pycache__ -rf
echo -e "\n===== Running smoke tests"
tox
}
function run_bumpversion {
echo -e "\n===== Bumping version"
bumpversion minor
}
function run_build
{
echo -e "\n===== Building Python Wheel"
python setup.py bdist_wheel
}
function run_twine
{
echo -e "\n===== Uploading to PyPi"
twine upload -u $PIPYUSER --repository-url $PIPYREPO dist/iotedgedev-$VERSION-py2.py3-none-any.whl
}
function run_build_docker
{
./docker/tool/build-docker.sh $PLATFORM
}
function run_push_docker
{
./docker/tool/push-docker.sh $1 $2
}
#run_tox
if [ "$MODE" = "prod" ]; then
run_bumpversion
fi
run_build
#run_twine
run_build_docker
#run_push_docker
#./docker/push-docker.sh $DOCKERHUB
echo -e "\n===== All done"