Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / shell / cmake-stage.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> cmake-stage.sh"
12
13 classifier="${CLASSIFIER:-linux-amd64}"
14 nexus_group_id="${NEXUS_GROUP_ID:-io.aswf.opencolorio}"
15 staging_profile_id="${STAGING_PROFILE_ID:-126694cb53ec54}"
16 version="${VERSION:-}"
17
18 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
19 source "/tmp/v/lftools/bin/activate"
20
21 set -eux -o pipefail
22
23 if [ -z "${nexus_group_id}" ]; then
24     echo "ERROR: No nexus group ID provided."
25     exit 1
26 fi
27
28 if [ -z "${staging_profile_id}" ]; then
29     echo "ERROR: No staging profile ID provided."
30     exit 1
31 fi
32
33 if [ -z "${version}" ]; then
34     if [ -f "/tmp/artifact_version" ]; then
35         version="$(cat /tmp/artifact_version)"
36     else
37         echo "ERROR: No artifact version defined."
38         exit 1
39     fi
40 fi
41
42 repo_id=$(lftools deploy nexus-stage-repo-create "$NEXUS_URL" \
43     "$staging_profile_id")
44
45 mapfile -t artifacts < <(ls "$WORKSPACE"/dist)
46 for artifact in "${artifacts[@]}"; do
47     lftools deploy file -c "$classifier" "$NEXUS_URL" "$repo_id" \
48         "$nexus_group_id" \
49         "${artifact%.tar.xz}" \
50         "$version" \
51         tar.xz \
52         "$WORKSPACE/dist/$artifact"
53
54     # Create src tar
55     git config tar.tar.xz.command "xz -c"
56     git archive --format=tar.xz HEAD > src.tar.xz
57     lftools deploy file -c "sources" "$NEXUS_URL" "$repo_id" \
58         "$nexus_group_id" \
59         "${artifact%.tar.xz}" \
60         "$version" \
61         tar.xz \
62         src.tar.xz
63 done
64
65 lftools deploy nexus-stage-repo-close "$NEXUS_URL" "$staging_profile_id" \
66     "$repo_id"
67
68 PATCH_DIR="$WORKSPACE/archives/patches"
69 mkdir -p "$PATCH_DIR"
70 echo "$PROJECT" "$(git rev-parse --verify HEAD)" | \
71     tee -a "$PATCH_DIR/taglist.log"
72 echo "$repo_id" > "$WORKSPACE/archives/staging-repo.txt"