-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhelm.sh
executable file
·86 lines (75 loc) · 1.83 KB
/
helm.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
#!/usr/bin/env bash
# This script creates a Helm package for the given version. It will output a
# .tgz file at the specified path, and may optionally push it to the Coder OSS
# repo.
#
# ./helm.sh [--version 1.2.3] [--output path/to/coder.tgz] [--push]
#
# If no version is specified, defaults to the version from ./version.sh.
#
# If no output path is specified, defaults to
# "$repo_root/build/coder_logstream_kube_helm_$version.tgz".
#
# If the --push parameter is specified, the resulting artifact will be published
# to the Coder OSS repo. This requires `gsutil` to be installed and configured.
set -euo pipefail
cd $(dirname $(dirname "${BASH_SOURCE[0]}"))
log() {
echo "$*" 1>&2
}
version=""
output_path=""
push=0
args="$(getopt -o "" -l version:,output:,push -- "$@")"
eval set -- "$args"
while true; do
case "$1" in
--version)
version="$2"
shift 2
;;
--output)
output_path="$(realpath "$2")"
shift 2
;;
--push)
push="1"
shift
;;
--)
shift
break
;;
*)
error "Unrecognized option: $1"
;;
esac
done
version="${version}"
if [[ "$version" == "" ]]; then
version="$(./scripts/version.sh)"
fi
if [[ "$output_path" == "" ]]; then
mkdir -p build
output_path="$(realpath "build/$version.tgz")"
fi
# Make a destination temporary directory, as you cannot fully control the output
# path of `helm package` except for the directory name :/
temp_dir="$(mktemp -d)"
cd .
mkdir -p build
cp ./LICENSE build
cp -r helm/* build
log "--- Packaging helm chart for version $version ($output_path)"
helm package \
--version "$version" \
--app-version "$version" \
--destination "$temp_dir" \
./build 1>&2
log "Moving helm chart to $output_path"
cp "$temp_dir"/*.tgz "$output_path"
rm -rf "$temp_dir"
if [[ "$push" == 1 ]]; then
log "--- Publishing helm chart..."
# TODO: figure out how/where we want to publish the helm chart
fi