aboutsummaryrefslogtreecommitdiffstats
path: root/screwdriver/update-vespa-version-in-sample-apps.sh
blob: dbcb5d46c3a207a88054ca5b6adb65e50f5e9956 (plain) (blame)
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
#!/usr/bin/ssh-agent /bin/bash
# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

set -euo pipefail
set -x

if [[ $# -ne 1 ]]; then
    echo "Usage: $0 <Vespa version>"
    exit 1
fi

readonly VESPA_RELEASE="$1"
readonly TRUE="true"
readonly FALSE="false"

export JAVA_HOME=$(dirname $(dirname $(readlink -f /usr/bin/java)))

function is_published {
    BUNDLE_PLUGIN_HTTP_CODE=$(curl --write-out %{http_code} --silent --location --output /dev/null https://repo.maven.apache.org/maven2/com/yahoo/vespa/bundle-plugin/${VESPA_RELEASE}/)
    if [ $BUNDLE_PLUGIN_HTTP_CODE = "200" ] ; then
        echo "$TRUE"
    else
        echo "$FALSE"
    fi
}

function wait_until_published {
    cnt=0
    until [[ $(is_published) = "$TRUE" ]]; do
        ((cnt+=1))
        # Wait max 60 minutes
        if (( $cnt > 60 )); then
            echo "ERROR: Artifacts with version ${VESPA_RELEASE} not found on central maven repo."
            exit 1
        fi
        echo "Waiting 60 seconds for version ${VESPA_RELEASE} on central maven repo ($cnt times)."
        sleep 60
    done
}

wait_until_published

ssh-add -D
set +x
ssh-add <(echo $SAMPLE_APPS_DEPLOY_KEY | base64 -d)
set -x

git clone git@github.com:vespa-engine/sample-apps.git
cd sample-apps

# Update Vespa version property in pom.xml
mvn versions:set-property -Dproperty=vespa_version -DnewVersion=${VESPA_RELEASE}

changes=$(git status --porcelain | wc -l)

if (( changes > 0 )); then
    echo "Updating Vespa version to ${VESPA_RELEASE}."
    git commit -a -m "Update Vespa version to ${VESPA_RELEASE}."
    git pull --rebase
    git push
fi