Rework creating tags & branches from release files
[releng.git] / jjb / releng / branch-or-tag.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018 The Linux Foundation and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 set -e -o pipefail
11
12 GIT_URL=${GIT_URL:-https://gerrit.opnfv.org/gerrit}
13 STREAM=${STREAM:-'nostream'}
14 RELEASE_FILES=$(git diff HEAD^1 --name-only -- "releases/$STREAM")
15
16 echo "--> Verifying $RELEASE_FILES."
17 for release_file in $RELEASE_FILES; do
18     # Verify the release file schema
19     python releases/scripts/verify_schema.py \
20     -s releases/schema.yaml \
21     -y $release_file
22 done
23
24 for release_file in $RELEASE_FILES; do
25     while read -r repo branch ref; do
26         echo "$repo" "$branch" "$ref"
27         unset branch_actual
28         branch_actual="$(git ls-remote "https://gerrit.opnfv.org/gerrit/$repo.git" "refs/heads/$branch" | awk '{print $1}')"
29
30         if [ -n "$branch_actual" ]; then
31             echo "$repo refs/heads/$branch already exists at $branch_actual"
32             echo "RUN releng-release-create-venv.sh"
33             source jjb/releng/releng-release-tagging.sh
34         else
35             echo "This is a branching job"
36             source jjb/releng/releng-release-create-branch.sh
37         fi
38
39     done  < <(python releases/scripts/repos.py -b -f "$release_file")
40 done