-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpush-to-quay.sh
executable file
·47 lines (31 loc) · 1.94 KB
/
push-to-quay.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
#!/bin/bash
set -o pipefail
set -eu
location=$(dirname $0)
PACKAGE=knative-camel-operator-dev
BASE_VERSION=0.18.0
update_manifest() {
local version=$1
local manifest_dir=$location/deploy/olm-catalog/knative-camel-operator-dev
echo "Renaming manifest dir"
old_version=""
for dir in $manifest_dir/*/; do
dir=${dir%*/}
current=$(basename $dir)
if [ "$current" != "$version" ]; then
old_version=$current
mv $dir $manifest_dir/$version
fi
done
echo "Old version was $old_version"
echo "Updating Manifest"
sed -i "s/^ version\: .*$/ version: $version/" $location/deploy/olm-catalog/knative-camel-operator-dev/$version/knative-camel-operator.clusterserviceversion.yaml
sed -i "s/^ replaces\: .*$/ replaces: knative-camel-operator.v$old_version/" $location/deploy/olm-catalog/knative-camel-operator-dev/$version/knative-camel-operator.clusterserviceversion.yaml
sed -i "s/^ createdAt\: .*$/ createdAt: \"$(date --iso-8601=seconds)\"/" $location/deploy/olm-catalog/knative-camel-operator-dev/$version/knative-camel-operator.clusterserviceversion.yaml
sed -i "s/^\(.*\)name\: knative-camel-operator\.v.*$/\1name: knative-camel-operator.v$version/" $location/deploy/olm-catalog/knative-camel-operator-dev/$version/knative-camel-operator.clusterserviceversion.yaml
sed -i "s/^\(.*\)currentCSV\: knative-camel-operator\.v.*$/\1currentCSV: knative-camel-operator.v$version/" $location/deploy/olm-catalog/knative-camel-operator-dev/knative-camel-operator.package.yaml
}
new_version=$BASE_VERSION-$(date '+%Y%m%d%H%M%S')
update_manifest $new_version
export AUTH_TOKEN=$(curl -sH "Content-Type: application/json" -XPOST https://quay.io/cnr/api/v1/users/login -d '{"user": {"username": "'"${QUAY_USERNAME}"'", "password": "'"${QUAY_PASSWORD}"'"}}' | jq -r '.token')
operator-courier --verbose push deploy/olm-catalog/${PACKAGE}/ ${QUAY_USERNAME} ${PACKAGE} ${new_version} "$AUTH_TOKEN"