Prepare 2023.2 release jobs
[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 set -x
12
13 GIT_URL=${GIT_URL:-https://gerrit.opnfv.org/gerrit}
14 STREAM=${STREAM:-'nostream'}
15 RELEASE_FILES=$(git diff HEAD^1 --name-only -- "releases/$STREAM")
16
17 echo "--> Verifying $RELEASE_FILES."
18 for release_file in $RELEASE_FILES; do
19     # Verify the release file schema
20     python3 releases/scripts/verify_schema.py \
21     -s releases/schema.yaml \
22     -y $release_file
23 done
24
25 for release_file in $RELEASE_FILES; do
26     while read -r repo branch ref; do
27         echo "$repo" "$branch" "$ref"
28         unset branch_actual
29         branch_actual="$(git ls-remote "https://gerrit.opnfv.org/gerrit/$repo.git" "refs/heads/$branch" | awk '{print $1}')"
30
31         if [ -n "$branch_actual" ]; then
32             echo "$repo refs/heads/$branch already exists at $branch_actual"
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  < <(python3 releases/scripts/repos.py -b -f "$release_file")
40 done