forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel-info.sh
executable file
·122 lines (106 loc) · 2.68 KB
/
channel-info.sh
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
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
#
# Computes the current branch names of the edge, beta and stable
# channels, as well as the latest tagged release for beta and stable.
#
# stdout of this script may be eval-ed
#
here="$(dirname "$0")"
# shellcheck source=ci/semver_bash/semver.sh
source "$here"/semver_bash/semver.sh
remote=https://github.com/solana-labs/solana.git
# Fetch all vX.Y.Z tags
#
# NOTE: pre-release tags are explicitly ignored
#
# shellcheck disable=SC2207
tags=( \
$(git ls-remote --tags $remote \
| cut -c52- \
| grep '^v[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*$' \
| cut -c2- \
) \
)
# Fetch all the vX.Y branches
#
# shellcheck disable=SC2207
heads=( \
$(git ls-remote --heads $remote \
| cut -c53- \
| grep '^v[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*$' \
| cut -c2- \
) \
)
# Figure the beta channel by looking for the largest vX.Y branch
beta=
for head in "${heads[@]}"; do
if [[ -n $beta ]]; then
if semverLT "$head.0" "$beta.0"; then
continue
fi
fi
beta=$head
done
# Figure the stable channel by looking for the second largest vX.Y branch
stable=
for head in "${heads[@]}"; do
if [[ $head = "$beta" ]]; then
continue
fi
if [[ -n $stable ]]; then
if semverLT "$head.0" "$stable.0"; then
continue
fi
fi
stable=$head
done
for tag in "${tags[@]}"; do
if [[ -n $beta && $tag = $beta* ]]; then
if [[ -n $beta_tag ]]; then
if semverLT "$tag" "$beta_tag"; then
continue
fi
fi
beta_tag=$tag
fi
if [[ -n $stable && $tag = $stable* ]]; then
if [[ -n $stable_tag ]]; then
if semverLT "$tag" "$stable_tag"; then
continue
fi
fi
stable_tag=$tag
fi
done
EDGE_CHANNEL=master
BETA_CHANNEL=${beta:+v$beta}
STABLE_CHANNEL=${stable:+v$stable}
BETA_CHANNEL_LATEST_TAG=${beta_tag:+v$beta_tag}
STABLE_CHANNEL_LATEST_TAG=${stable_tag:+v$stable_tag}
if [[ -n $CI_BASE_BRANCH ]]; then
BRANCH="$CI_BASE_BRANCH"
elif [[ -n $CI_BRANCH ]]; then
BRANCH="$CI_BRANCH"
fi
if [[ -z "$CHANNEL" ]]; then
if [[ $BRANCH = "$STABLE_CHANNEL" ]]; then
CHANNEL=stable
elif [[ $BRANCH = "$EDGE_CHANNEL" ]]; then
CHANNEL=edge
elif [[ $BRANCH = "$BETA_CHANNEL" ]]; then
CHANNEL=beta
fi
fi
if [[ $CHANNEL = beta ]]; then
CHANNEL_LATEST_TAG="$BETA_CHANNEL_LATEST_TAG"
elif [[ $CHANNEL = stable ]]; then
CHANNEL_LATEST_TAG="$STABLE_CHANNEL_LATEST_TAG"
fi
echo EDGE_CHANNEL="$EDGE_CHANNEL"
echo BETA_CHANNEL="$BETA_CHANNEL"
echo BETA_CHANNEL_LATEST_TAG="$BETA_CHANNEL_LATEST_TAG"
echo STABLE_CHANNEL="$STABLE_CHANNEL"
echo STABLE_CHANNEL_LATEST_TAG="$STABLE_CHANNEL_LATEST_TAG"
echo CHANNEL="$CHANNEL"
echo CHANNEL_LATEST_TAG="$CHANNEL_LATEST_TAG"
exit 0