-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpublish-release.sh
executable file
·95 lines (72 loc) · 2.53 KB
/
publish-release.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
#!/usr/bin/env bash
# Push operator image to docker hub and produce related yaml file
# Publish a qserv-operator release
# @author Fabrice Jammes, IN2P3
set -exuo pipefail
release=true
OP_VERSION=""
releasetag=""
DIR=$(cd "$(dirname "$0")"; pwd -P)
usage() {
cat << EOD
Usage: `basename $0` [options] [RELEASE_TAG]
Available options:
-h this message
-m minimal release, with not tag, used to publish from a ticket branch
Create a qserv-operator release tagged "RELEASE_TAG"
- Release tag template YYYY.M.<i>-rc<j>, i and j are integers
- Create a git release tag and use it to tag qserv-operator image
- Push operator image to docker hub
- Produce operator.yaml and operator-ns-scoped.yaml
- Produce operatorHub bundle in bundle/ directory
EOD
}
# get the options
while getopts hm c ; do
case $c in
h) usage ; exit 0 ;;
m) release=false ;;
\?) usage ; exit 2 ;;
esac
done
shift `expr $OPTIND - 1`
if [ $# -gt 1 ] ; then
usage
exit 2
fi
if [ $# -eq 1 ] ; then
releasetag="$1"
export OP_VERSION="$1"
message="Publish release"
else
message="Publish version"
fi
if [[ "$releasetag" =~ '/' || "$releasetag" =~ '\' ]]
then
>&2 echo "ERROR: Found '\' or '/' in release tag $releasetag"
exit 1
fi
. "$DIR/env.build.sh"
$DIR/build.sh
$DIR/push-image.sh
make yaml yaml-ns-scoped
if [ "$release" = true ]; then
echo "Update Qserv images in manifests/base/image.yaml"
sed -ri "s/^(\s*image: qserv\/.*:).*/\1$releasetag/" $DIR/manifests/base/image.yaml
echo "Update release number in documentation"
find $DIR/doc -type f -print0 | xargs -0 sed -ri "s/RELEASE=\".*\"/RELEASE=\"$releasetag\"/"
sed -ri "s/RELEASE=\".*\"/RELEASE=\"$releasetag\"/" $DIR/README.md
# Prepare operatorHub files
# Edit 'replaces', 'image' and 'containerImage' fields in config/manifests/bases/qserv-operator.clusterserviceversion.yaml
csv_file="$DIR/config/manifests/bases/qserv-operator.clusterserviceversion.yaml"
sample_file="$DIR/config/samples/qserv_v1beta1_qserv.yaml"
previous_version=$(grep -oP 'qserv\/qserv-operator:([0-9]+\.[0-9]+\.[0-9](-rc[0-9]+)?)' "$csv_file" | cut -d: -f2)
sed -ri "s/(202[0-9]+\.[0-9]+\.[0-9](-rc[0-9]+)?)/$releasetag/" "$sample_file" "$csv_file"
sed -ri "s/replaces: qserv-operator\.v([0-9]+\.[0-9]+\.[0-9](-rc[0-9]+)?)/replaces: qserv-operator\.v$previous_version/" "$csv_file"
fi
git add .
git commit -m "$message $VERSION" || echo "Nothing to commit"
if [ "$release" = true ]; then
git tag -a "$releasetag" -m "Version $releasetag"
git push --follow-tags
fi