|
3 | 3 | CBL_VERSION=$1 |
4 | 4 | VS_VERSION=$2 |
5 | 5 |
|
6 | | -dir=$( dirname -- $(realpath "$0"); ) |
7 | | - |
8 | | -# Get latest good CBL iOS EE build for given version |
9 | | -CBL_URL="http://proget.build.couchbase.com:8080/api/open_latestbuilds?product=couchbase-lite-ios&version=${cbl_version}" |
| 6 | +if [ -z "${CBL_VERSION}" ] || [ -z "${VS_VERSION}" ]; then |
| 7 | + echo "Usage: $0 <CBL_VERSION> <VS_VERSION>" |
| 8 | + exit 1 |
| 9 | +fi |
10 | 10 |
|
11 | | -# Grab the redirect url |
12 | | -CBL_SOURCE_URL=$(curl -s -L -o /dev/null -w '%{url_effective}' "${CBL_URL}") |
| 11 | +dir=$( dirname -- $(realpath "$0") ) |
13 | 12 |
|
14 | 13 | CBL="http://proget.build.couchbase.com:8080/api/get_version?product=couchbase-lite-ios&version=${CBL_VERSION}" |
15 | 14 | RESPONSE=$(curl -s $CBL) |
16 | | -CBL_IS_RELEASE=$(echo -n $RESPONSE | jq .IsRelease) |
17 | | -CBL_BUILD_NO=$(echo -n $RESPONSE | jq .BuildNumber) |
| 15 | +CBL_IS_RELEASE=$(echo -n "$RESPONSE" | jq .IsRelease) |
| 16 | +CBL_BUILD_NO=$(echo -n "$RESPONSE" | jq .BuildNumber) |
18 | 17 |
|
19 | | -if [ "${CBL_BUILD_NO}" == "" ] |
| 18 | +if [ "${CBL_BUILD_NO}" == "" ] || [ "${CBL_BUILD_NO}" == "null" ] |
20 | 19 | then |
21 | 20 | echo "No latest successful build found for CBL v${CBL_VERSION}" |
22 | 21 | exit 3 |
23 | 22 | fi |
24 | 23 |
|
25 | 24 | VS="http://proget.build.couchbase.com:8080/api/get_version?product=couchbase-lite-ios-vector-search&version=${VS_VERSION}&ee=true" |
26 | 25 | RESPONSE=$(curl -s $VS) |
27 | | -VS_BUILD_NO=$(echo -n $RESPONSE | jq .BuildNumber) |
| 26 | +VS_IS_RELEASE=$(echo -n "$RESPONSE" | jq .IsRelease) |
| 27 | +VS_BUILD_NO=$(echo -n "$RESPONSE" | jq .BuildNumber) |
28 | 28 |
|
29 | | -if [ "${VS_BUILD_NO}" == "" ] |
| 29 | +if [ "${VS_BUILD_NO}" == "" ] || [ "${VS_BUILD_NO}" == "null" ] |
30 | 30 | then |
31 | 31 | echo "No latest successful build found for VS v${VS_VERSION}" |
32 | 32 | exit 3 |
33 | 33 | fi |
34 | 34 |
|
| 35 | +# Download VS extension once (platform-independent) |
| 36 | +if [ "${VS_IS_RELEASE}" == "true" ]; then |
| 37 | + VS_PACKAGE_NAME="couchbase-lite-vector-search-${VS_VERSION}-apple.zip" |
| 38 | + VS_URL="https://latestbuilds.service.couchbase.com/builds/releases/mobile/couchbase-lite-vector-search/${VS_VERSION}/${VS_PACKAGE_NAME}" |
| 39 | +else |
| 40 | + VS_PACKAGE_NAME="couchbase-lite-vector-search-${VS_VERSION}-${VS_BUILD_NO}-apple.zip" |
| 41 | + VS_URL="https://latestbuilds.service.couchbase.com/builds/latestbuilds/couchbase-lite-vector-search/${VS_VERSION}/${VS_BUILD_NO}/${VS_PACKAGE_NAME}" |
| 42 | +fi |
| 43 | + |
| 44 | +VS_DOWNLOAD_DIR="${dir}/../vs_downloaded" |
| 45 | +rm -rf "${VS_DOWNLOAD_DIR}" |
| 46 | +mkdir -p "${VS_DOWNLOAD_DIR}" |
| 47 | +wget -P "${VS_DOWNLOAD_DIR}" "${VS_URL}" |
| 48 | + |
35 | 49 | for PLATFORM in "objc" "swift" |
36 | 50 | do |
37 | 51 | echo $PLATFORM |
38 | 52 | pushd "${dir}/../modules/${PLATFORM}/examples" |
39 | 53 |
|
40 | 54 | # In case script fails mid-way, cleanup on start |
41 | | - if [ -d "downloaded" ]; then |
42 | | - rm -rf "downloaded" |
43 | | - fi |
| 55 | + rm -rf "downloaded" |
44 | 56 | mkdir -p downloaded |
45 | 57 |
|
46 | 58 | pushd downloaded |
47 | | - # Get CBL |
48 | | - CBL_SOURCE_URL=$(curl -s -L -o /dev/null -w '%{url_effective}' "http://proget.build.couchbase.com:8080/api/open_latestbuilds?product=couchbase-lite-ios&version=${CBL_VERSION}") |
49 | 59 |
|
50 | | - if [ $CBL_IS_RELEASE == true ]; then |
| 60 | + # Get CBL |
| 61 | + if [ "${CBL_IS_RELEASE}" == "true" ]; then |
51 | 62 | CBL_PACKAGE_NAME="couchbase-lite-${PLATFORM}_xc_enterprise_${CBL_VERSION}.zip" |
| 63 | + CBL_URL="https://latestbuilds.service.couchbase.com/builds/releases/mobile/couchbase-lite-ios/${CBL_VERSION}/${CBL_PACKAGE_NAME}" |
52 | 64 | else |
53 | 65 | CBL_PACKAGE_NAME="couchbase-lite-${PLATFORM}_xc_enterprise_${CBL_VERSION}-${CBL_BUILD_NO}.zip" |
| 66 | + CBL_URL="https://latestbuilds.service.couchbase.com/builds/latestbuilds/couchbase-lite-ios/${CBL_VERSION}/${CBL_BUILD_NO}/${CBL_PACKAGE_NAME}" |
54 | 67 | fi |
55 | 68 |
|
56 | | - wget "$CBL_SOURCE_URL$CBL_PACKAGE_NAME" |
57 | | - unzip -o $CBL_PACKAGE_NAME -d "../Frameworks/" |
| 69 | + wget "${CBL_URL}" |
| 70 | + unzip -o "${CBL_PACKAGE_NAME}" -d "../Frameworks/" |
58 | 71 |
|
59 | 72 | # Get VS extension |
60 | | - VS_SOURCE_URL=$(curl -s -L -o /dev/null -w '%{url_effective}' "http://proget.build.couchbase.com:8080/api/open_latestbuilds?product=couchbase-lite-ios-vector-search&version=${VS_VERSION}") |
61 | | - echo $VS_SOURCE_URL |
62 | | - VS_PACKAGE_NAME="couchbase-lite-vector-search-${VS_VERSION}-${VS_BUILD_NO}-apple.zip" |
63 | | - wget "$VS_SOURCE_URL$VS_PACKAGE_NAME" |
64 | | - unzip -o $VS_PACKAGE_NAME -d "../Frameworks/" |
65 | | - |
66 | | - # Check if download was successful |
67 | | - if [ $? -eq 0 ]; then |
68 | | - echo "Package downloaded successfully." |
69 | | - else |
70 | | - echo "Failed to download the package." |
71 | | - fi |
| 73 | + unzip -o "${VS_DOWNLOAD_DIR}/${VS_PACKAGE_NAME}" -d "../Frameworks/" |
72 | 74 |
|
73 | 75 | popd |
74 | 76 |
|
|
79 | 81 | popd |
80 | 82 |
|
81 | 83 | done |
| 84 | + |
| 85 | +rm -rf "${VS_DOWNLOAD_DIR}" |
0 commit comments