Skip to content

Commit 876f3f0

Browse files
ArunTejChmpenick
authored andcommitted
PHP-203: Added build.yaml for automating builds
1 parent 0f6a3f0 commit 876f3f0

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

build.yaml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
schedules:
2+
adhoc:
3+
schedule: adhoc
4+
branches:
5+
include: [master]
6+
architecture:
7+
- x64
8+
os:
9+
- ubuntu/trusty64/cpp
10+
- ubuntu/xenial64
11+
- centos/6-64
12+
- centos/7-64
13+
build:
14+
- script: |
15+
echo "Running packaging job"
16+
package:
17+
include: # list of files and glob paths to include in the artifact, relative to the current working directory
18+
- ext/packaging/packages/*
19+
release:
20+
after:
21+
each:
22+
- script: |
23+
LIBUV_VERSION=1.13.1
24+
LIBUV_SUBVERSION=1
25+
TOKENS=($(echo ${OS_VERSION} | tr "/" " "))
26+
DISTRO=${TOKENS[0]}
27+
RELEASE=${TOKENS[1]}
28+
CPP_DRIVER_VERSION=2.7.0
29+
CPP_DRIVER_SUBVERSION=1
30+
31+
if [ "${DISTRO}" = "ubuntu" ]; then
32+
NAME=$(echo ${RELEASE%??})
33+
ARCHITECTURE=${RELEASE:-2}
34+
PACKAGE_TYPE=deb
35+
PACKAGE_INSTALL="dpkg -i"
36+
PACKAGE_UTILITY="apt-get"
37+
PHP_VERSIONS=( php5.6-dev php7.0-dev php7.1-dev )
38+
if [ "${NAME}" = "trusty" ]; then
39+
RELEASE=14.04
40+
elif [ "${NAME}" = "xenial" ]; then
41+
RELEASE=16.04
42+
else
43+
printf "Unsupported Ubuntu Version: %s\n" ${RELEASE}
44+
exit 1
45+
fi
46+
CPP_DRIVER_SUFFIX=_$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}_amd64.deb
47+
CPP_DEV_DRIVER_SUFFIX=-dev_$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}_amd64.deb
48+
LIBUV_SUFFIX=_${LIBUV_VERSION}-${LIBUV_SUBVERSION}_amd64.deb
49+
LIBUV_DEV_SUFFIX=-dev_${LIBUV_VERSION}-${LIBUV_SUBVERSION}_amd64.deb
50+
51+
elif [ "${DISTRO}" = "centos" ]; then
52+
TOKENS=($(echo ${RELEASE} | tr "-" " "))
53+
NAME=${DISTRO}
54+
RELEASE=${TOKENS[0]}
55+
ARCHITECTURE=${TOKENS[1]}
56+
PACKAGE_TYPE=rpm
57+
PACKAGE_INSTALL="rpm -i"
58+
PACKAGE_UTILITY="yum"
59+
PHP_VERSIONS=( php56w-devel php70w-devel php71w-devel )
60+
if [ "${RELEASE}" = "7" ]; then
61+
CPP_DRIVER_SUFFIX=-$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}.el${RELEASE}.centos.x86_64.rpm
62+
CPP_DEV_DRIVER_SUFFIX=-devel-$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}.el${RELEASE}.centos.x86_64.rpm
63+
LIBUV_SUFFIX=-${LIBUV_VERSION}-${LIBUV_SUBVERSION}.el7.centos.x86_64.rpm
64+
LIBUV_DEV_SUFFIX=-devel-${LIBUV_VERSION}-${LIBUV_SUBVERSION}.el7.centos.x86_64.rpm
65+
elif [ "${RELEASE}" = "6" ]; then
66+
CPP_DRIVER_SUFFIX=-$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}.el${RELEASE}.x86_64.rpm
67+
CPP_DEV_DRIVER_SUFFIX=-devel-$CPP_DRIVER_VERSION-${CPP_DRIVER_SUBVERSION}.el${RELEASE}.x86_64.rpm
68+
LIBUV_SUFFIX=-${LIBUV_VERSION}-${LIBUV_SUBVERSION}.el6.x86_64.rpm
69+
LIBUV_DEV_SUFFIX=-devel-${LIBUV_VERSION}-${LIBUV_SUBVERSION}.el6.x86_64.rpm
70+
else
71+
printf "Unsupported Centos Version: %s\n" ${RELEASE}
72+
exit 1
73+
fi
74+
else
75+
printf "Unsupported OS: %s\n" ${OS_VERSION}
76+
exit 1
77+
fi
78+
79+
PACKAGE_UTILITY_INSTALL="${PACKAGE_UTILITY} install -y"
80+
PACKAGE_UTILITY_REMOVE="${PACKAGE_UTILITY} remove -y"
81+
82+
CPP_DRIVER_BASE_URL=http://downloads.datastax.com/cpp-driver/$DISTRO/$RELEASE/cassandra/v$CPP_DRIVER_VERSION/cassandra-cpp-driver
83+
LIBUV_BASE_URL=http://downloads.datastax.com/cpp-driver/$DISTRO/$RELEASE/dependencies/libuv/v$LIBUV_VERSION/libuv
84+
85+
pushd ext/packaging
86+
mkdir packages
87+
88+
# Download and Install libuv
89+
wget ${LIBUV_BASE_URL}${LIBUV_SUFFIX} ${LIBUV_BASE_URL}${LIBUV_DEV_SUFFIX}
90+
sudo ${PACKAGE_INSTALL} libuv*.${PACKAGE_TYPE}
91+
92+
# Download and Install cpp core drivers
93+
wget ${CPP_DRIVER_BASE_URL}${CPP_DRIVER_SUFFIX} ${CPP_DRIVER_BASE_URL}${CPP_DEV_DRIVER_SUFFIX}
94+
sudo ${PACKAGE_INSTALL} cassandra-cpp-driver*.${PACKAGE_TYPE}
95+
96+
# Build, package and upload DataStax PHP driver
97+
echo "Building DataStax PHP driver ..."
98+
for PHP_VERSION in "${PHP_VERSIONS[@]}"
99+
do
100+
sudo ${PACKAGE_UTILITY_INSTALL} ${PHP_VERSION}
101+
./build_${PACKAGE_TYPE}.sh
102+
find build -type f -name "*.${PACKAGE_TYPE}" -exec mv {} packages \;
103+
rm -rf build
104+
PHP_TOKENS=($(echo ${PHP_VERSION} | tr "-" " "))
105+
sudo ${PACKAGE_UTILITY_REMOVE} ${PHP_TOKENS[0]}-common
106+
done
107+
pushd packages
108+
# Uploading driver packages
109+
curl -$ARTIFACTORY_CREDS -T "{$(echo php*-cassandra-driver* | tr ' ' ',')}" "https://datastax.jfrog.io/datastax/cpp-php-drivers/php-driver/builds/{$BUILD_NUMBER}/$DISTRO/$RELEASE/cassandra/$version/"
110+
popd

0 commit comments

Comments
 (0)