2018-06-06 15:42:53 +02:00
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
2018-11-07 19:06:20 +01:00
|
|
|
|
# Copyright The Helm Authors. All rights reserved.
|
2018-06-06 15:42:53 +02:00
|
|
|
|
#
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
|
#
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
#
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
|
set -o nounset
|
|
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
2019-11-28 19:09:20 +01:00
|
|
|
|
SCRIPT_DIR=$(dirname -- "$(readlink -e "${BASH_SOURCE[0]}" || realpath "${BASH_SOURCE[0]}")")
|
|
|
|
|
|
readonly SCRIPT_DIR
|
2018-06-06 15:42:53 +02:00
|
|
|
|
|
|
|
|
|
|
show_help() {
|
2019-11-02 20:44:02 +01:00
|
|
|
|
cat << EOF
|
2018-11-07 19:06:20 +01:00
|
|
|
|
Usage: $(basename "$0") <options>
|
|
|
|
|
|
|
|
|
|
|
|
Build ct using Goreleaser.
|
|
|
|
|
|
|
|
|
|
|
|
-h, --help Display help
|
|
|
|
|
|
-d, --debug Display verbose output and run Goreleaser with --debug
|
|
|
|
|
|
-r, --release Create a release using Goreleaser. This includes the creation
|
|
|
|
|
|
of a GitHub release and building and pushing the Docker image.
|
|
|
|
|
|
If this flag is not specified, Goreleaser is run with --snapshot
|
2018-06-06 15:42:53 +02:00
|
|
|
|
EOF
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
main() {
|
2018-11-07 19:06:20 +01:00
|
|
|
|
local debug=
|
|
|
|
|
|
local release=
|
2018-06-06 15:42:53 +02:00
|
|
|
|
|
|
|
|
|
|
while :; do
|
|
|
|
|
|
case "${1:-}" in
|
2019-11-02 20:44:02 +01:00
|
|
|
|
-h | --help)
|
2018-06-06 15:42:53 +02:00
|
|
|
|
show_help
|
|
|
|
|
|
exit
|
|
|
|
|
|
;;
|
2019-11-02 20:44:02 +01:00
|
|
|
|
-d | --debug)
|
2018-11-07 19:06:20 +01:00
|
|
|
|
debug=true
|
2018-06-06 15:42:53 +02:00
|
|
|
|
;;
|
2019-11-02 20:44:02 +01:00
|
|
|
|
-r | --release)
|
2018-11-07 19:06:20 +01:00
|
|
|
|
release=true
|
2018-06-06 15:42:53 +02:00
|
|
|
|
;;
|
|
|
|
|
|
*)
|
|
|
|
|
|
break
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
shift
|
|
|
|
|
|
done
|
|
|
|
|
|
|
2023-03-24 15:12:04 +01:00
|
|
|
|
local goreleaser_args=(--clean)
|
2018-06-06 15:42:53 +02:00
|
|
|
|
|
2018-11-07 19:06:20 +01:00
|
|
|
|
if [[ -n "$debug" ]]; then
|
2019-11-02 20:44:02 +01:00
|
|
|
|
goreleaser_args+=(--debug)
|
2018-11-07 19:06:20 +01:00
|
|
|
|
set -x
|
|
|
|
|
|
fi
|
2018-06-06 15:42:53 +02:00
|
|
|
|
|
2018-11-07 19:06:20 +01:00
|
|
|
|
if [[ -z "$release" ]]; then
|
2024-04-21 09:13:08 +02:00
|
|
|
|
goreleaser_args+=(--snapshot --skip=sign)
|
2018-06-06 15:42:53 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
2018-11-07 19:06:20 +01:00
|
|
|
|
pushd "$SCRIPT_DIR" > /dev/null
|
|
|
|
|
|
|
2021-05-20 16:01:43 +02:00
|
|
|
|
go test -race ./...
|
2018-11-07 19:06:20 +01:00
|
|
|
|
goreleaser "${goreleaser_args[@]}"
|
|
|
|
|
|
|
|
|
|
|
|
popd > /dev/null
|
2018-06-06 15:42:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
main "$@"
|