forked from galasa-dev/automation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-build-galasa-mono-repo.sh
More file actions
executable file
·112 lines (92 loc) · 3.63 KB
/
10-build-galasa-mono-repo.sh
File metadata and controls
executable file
·112 lines (92 loc) · 3.63 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#! /usr/bin/env bash
#
# Copyright contributors to the Galasa project
#
# SPDX-License-Identifier: EPL-2.0
#
#-----------------------------------------------------------------------------------------
#
# Objectives: Build all the code in github release/prerelease branches.
#
# Environment variable over-rides:
#
#-----------------------------------------------------------------------------------------
# Where is this script executing from ?
BASEDIR=$(dirname "$0");pushd $BASEDIR 2>&1 >> /dev/null ;BASEDIR=$(pwd);popd 2>&1 >> /dev/null
# echo "Running from directory ${BASEDIR}"
export ORIGINAL_DIR=$(pwd)
# cd "${BASEDIR}"
cd "${BASEDIR}/.."
WORKSPACE_DIR=$(pwd)
#-----------------------------------------------------------------------------------------
#
# Set Colors
#
#-----------------------------------------------------------------------------------------
bold=$(tput bold)
underline=$(tput sgr 0 1)
reset=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 76)
white=$(tput setaf 7)
tan=$(tput setaf 202)
blue=$(tput setaf 25)
#-----------------------------------------------------------------------------------------
#
# Headers and Logging
#
#-----------------------------------------------------------------------------------------
underline() { printf "${underline}${bold}%s${reset}\n" "$@" ;}
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@" ;}
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@" ;}
debug() { printf "${white}%s${reset}\n" "$@" ;}
info() { printf "${white}➜ %s${reset}\n" "$@" ;}
success() { printf "${green}✔ %s${reset}\n" "$@" ;}
error() { printf "${red}✖ %s${reset}\n" "$@" ;}
warn() { printf "${tan}➜ %s${reset}\n" "$@" ;}
bold() { printf "${bold}%s${reset}\n" "$@" ;}
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@" ;}
#-----------------------------------------------------------------------------------------
# Main logic.
#-----------------------------------------------------------------------------------------
mkdir -p temp
function ask_user_for_release_type {
PS3="Select the type of release process please: "
select lng in release pre-release
do
case $lng in
"release")
export release_type="release"
break
;;
"pre-release")
export release_type="prerelease"
break
;;
*)
echo "Unrecognised input.";;
esac
done
echo "Chosen type of release process: ${release_type}"
}
function build_galasa_mono_repo {
info "About to start the Release Build Orchestrator for the 'galasa' repo"
workflow_dispatch=$( gh workflow run releases.yaml --repo galasa-dev/galasa --ref ${release_type} --field jacoco_enabled=false --field sign_artifacts=true)
if [[ $? != 0 ]]; then
error "Failed to start the workflow. $?"
exit 1
fi
# Sleep to give the workflow a chance to start
sleep 5
run_id=$(gh run list --repo galasa-dev/galasa --workflow releases.yaml --limit 1 --json databaseId --jq '.[0].databaseId')
if [[ $? != 0 ]]; then
error "Failed to get the workflow run_id. $?"
exit 1
fi
success "Release Build Orchestrator started with Run ID: ${run_id}"
bold "Now watch the workflow run to make sure it finishes successfully at https://github.com/galasa-dev/galasa/actions/runs/${run_id}"
}
if [[ "$CALLED_BY_PRERELEASE" == "" ]]; then
ask_user_for_release_type
build_galasa_mono_repo
fi