INFRA: Switch to tox for JJB verify and merge jobs
[infra/cicd.git] / jjb / geode-native / apache-geode-native-release / src_release.sh
1 #!/usr/bin/env bash
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2018-2019 Nordix Foundation.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19 set -o nounset
20 set -o errexit
21 set -o pipefail
22 #set -o xtrace
23
24 ARTIFACTORY_URL="https://artifactory.nordix.org/artifactory"
25 GEODE_VERSION=$(cd geode-native ; git describe --abbrev=0 --tags | sed -r "s#rel/v(.*)#\1#")
26 # Make sure the Geode tag version is in agreed format.
27 if [[ ${GEODE_VERSION} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]$ ]] ; then
28    GEODE_UPSTREAM_VERSION=$(echo ${GEODE_VERSION} | awk -F "." '{print $1"."$2"."$3}')
29    BUILD_DATE=$(date '+%Y%m%d%H%M')
30    GEODE_ARTIFACT="geode_client_src-${GEODE_VERSION}-NORDIX.${BUILD_DATE}.tgz"
31    tar czvf ${GEODE_ARTIFACT} geode-native/
32 else
33    echo "ERROR: Incorrect geode-native tag version on the branch: ${GEODE_VERSION}"
34    exit 1
35 fi
36
37 SHA_CHECKSUM=$(shasum -a 1 ${GEODE_ARTIFACT} | awk '{ print $1 }')
38 SHA256_CHECKSUM=$(sha256sum ${GEODE_ARTIFACT} | awk '{ print $1 }')
39 MD5_CHECKSUM=$(md5sum ${GEODE_ARTIFACT} | awk '{ print $1 }')
40 echo "-----------------------------------------------------------"
41 echo -e "\nUploading ${GEODE_ARTIFACT} to geode-client area: "
42 echo -e "geode-client/${GEODE_UPSTREAM_VERSION}/src on artifactory.nordix.org\n"
43 curl -H "X-JFrog-Art-Api:${ARTIFACTORY_API_KEY}" \
44      -H "X-Checksum-Sha1:${SHA_CHECKSUM}" \
45      -H "X-Checksum-Sha256:${SHA256_CHECKSUM}" \
46      -H "X-Checksum-MD5:${MD5_CHECKSUM}" \
47      -X PUT "${ARTIFACTORY_URL}/geode-client/${GEODE_UPSTREAM_VERSION}/src/${GEODE_ARTIFACT}" \
48      -T ${GEODE_ARTIFACT}
49 echo "-----------------------------------------------------------"