-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathclient-builder.sh
More file actions
executable file
·140 lines (123 loc) · 4.92 KB
/
client-builder.sh
File metadata and controls
executable file
·140 lines (123 loc) · 4.92 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
set -e
set -o pipefail
set -o nounset
# Default: NO skip
SKIP_BUILD_OPENCGA=false
SKIP_PYTHON=false
SKIP_RCLIENT=false
SKIP_JAVA=false
SKIP_JS=false
# Get the OpenCGA version from the Maven project
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
# Define the directory where the built clients will be stored
BUILD_DIR="./build"
DIST_DIR="$BUILD_DIR/dist"
CLIENTS_DIR="$BUILD_DIR/clients"
# Function to print main usage of the script
function print_usage() {
echo ""
echo "Build opencga clients."
echo ""
echo "Usage: $(basename "$0") [options]"
echo ""
echo " Options:"
echo " -b --skip-build-opencga FLAG Skip Build OpenCGA"
echo " -p --skip-python FLAG Skip Build OpenCGA Python client"
echo " -r --skip-r FLAG Skip Build OpenCGA R client"
echo " -w --skip-javascript FLAG Skip Build OpenCGA JavaScript client"
echo " -h --help FLAG Print this help and exit"
echo ""
}
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-b|--skip-build-opencga)
SKIP_BUILD_OPENCGA=true
shift
;;
-p|--skip-python )
SKIP_PYTHON=true
shift
;;
-r|--skip-r)
SKIP_RCLIENT=true
shift
;;
-w|--skip-javascript)
SKIP_JS=true
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "Error: Opción no reconocida '$1'"
print_usage
exit 1
;;
esac
done
if ! $SKIP_BUILD_OPENCGA; then
echo ">> Building OpenCGA..."
mvn clean install -DskipTests -DskipITs -DskipCheckstyle -DskipSpotBugs -DskipJavadoc --no-transfer-progress
fi
# Check if the build directory exists, and delete it to create a new one total clean
[ -d "${DIST_DIR}" ] && rm -rf "${DIST_DIR}"
# Create the directory for the clients distribution
mkdir -p ${DIST_DIR}
mkdir -p ${CLIENTS_DIR}
if ! $SKIP_RCLIENT; then
echo ">> Building OpenCGA R client..."
R_DIR="$CLIENTS_DIR/R"
mkdir -p "$R_DIR"
cp -r ./opencga-client/src/main/R $CLIENTS_DIR
R_VERSION=$(echo "$VERSION" | sed 's/-SNAPSHOT/.9000/g')
echo "Calculated R Version: $R_VERSION"
# Update the DESCRIPTION file with the calculated version
DESCRIPTION_FILE="$CLIENTS_DIR/R/DESCRIPTION"
echo "Updating $DESCRIPTION_FILE with version $R_VERSION"
sed -i "s/OPENCGA_R_VERSION/${R_VERSION}/" "$DESCRIPTION_FILE"
export DOCKER_BUILDKIT=1
docker build -t opencb/opencga-r-builder:dev -f opencga-app/app/cloud/docker/opencga-r-builder/Dockerfile opencga-app/app/cloud/docker/opencga-r-builder
docker run --rm --mount type=bind,source="$R_DIR",target=/opt/opencga/R --mount type=bind,source="$DIST_DIR",target=/opt/opencga opencb/opencga-r-builder:dev R CMD build /opt/opencga/R
rm -rf ${DIST_DIR}/R
fi
if ! $SKIP_PYTHON; then
echo ">> Building OpenCGA Python client..."
PYTHON_DIR="$CLIENTS_DIR/python"
mkdir -p "$PYTHON_DIR"
echo "Copying Python and R to $CLIENTS_DIR"
cp -r "./opencga-client/src/main/python" "$CLIENTS_DIR"
echo "Calculating Python version"
PYOPENCGA_VERSION=$(python3 "./opencga-app/app/scripts/calculate_pypi_version.py" "$VERSION")
echo "Calculated Python Version: ${PYOPENCGA_VERSION}"
echo "Updating setup.py with version ${PYOPENCGA_VERSION}"
sed -i "s/PYOPENCGA_VERSION/${PYOPENCGA_VERSION}/" "$CLIENTS_DIR/python/setup.py"
# ───────────────────────────────────────────────────────────────────
# 1) Create and activate an isolated virtual environment
VENV_DIR="$PYTHON_DIR/.venv"
python3 -m venv "$VENV_DIR"
. "$VENV_DIR/bin/activate"
# 2) Upgrade pip, setuptools, and wheel inside the venv
pip install --upgrade pip setuptools wheel
pip install packaging requests
# ───────────────────────────────────────────────────────────────────
./build/clients/python/python-build.sh build
PYPY_VERSION=$(python3 opencga-app/app/scripts/calculate_pypi_version.py "$VERSION")
echo ">> Compressing OpenCGA Python client..."
PYTHON_DIR="$CLIENTS_DIR/python"
ARCHIVE_NAME="opencga-python-client-$PYPY_VERSION.tar.gz"
echo ">> Compressing the Python client directory $PYTHON_DIR to $DIST_DIR/$ARCHIVE_NAME..."
tar -czf "$DIST_DIR/$ARCHIVE_NAME" -C "$PYTHON_DIR" .
fi
if ! $SKIP_JS; then
echo ">> Copying OpenCGA JavaScript client..."
JAVASCRIPT_DIR="$CLIENTS_DIR/javascript"
mkdir -p "$JAVASCRIPT_DIR"
cp -r ./opencga-client/src/main/javascript "$CLIENTS_DIR"
JAVASCRIPT_CLIENT_NAME="opencga-javascript-client-$VERSION.tar.gz"
echo ">> Compressing the Javascript client directory $JAVASCRIPT_DIR to $DIST_DIR/$JAVASCRIPT_CLIENT_NAME..."
tar -czf "$DIST_DIR/$JAVASCRIPT_CLIENT_NAME" -C "$JAVASCRIPT_DIR" .
fi