2018-10-25 19:47:26 +00:00
#!/bin/bash
2019-03-20 19:32:48 +00:00
# Copyright 2018 the Velero contributors.
2018-10-25 19:47:26 +00: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
2018-10-30 15:00:11 +00:00
if [ [ -z " ${ GITHUB_TOKEN } " ] ] ; then
2018-10-25 19:47:26 +00:00
echo "GITHUB_TOKEN must be set"
exit 1
fi
# TODO derive this from the major+minor version
if [ -z " ${ RELEASE_NOTES_FILE } " ] ; then
echo "RELEASE_NOTES_FILE must be set"
exit 1
fi
2021-07-06 20:14:46 +00:00
if [ -z " ${ REGISTRY } " ] ; then
echo "REGISTRY must be set"
exit 1
fi
2018-10-25 19:47:26 +00:00
GIT_DIRTY = $( git status --porcelain 2> /dev/null)
if [ [ -z " ${ GIT_DIRTY } " ] ] ; then
export GIT_TREE_STATE = clean
else
export GIT_TREE_STATE = dirty
fi
2023-04-11 08:27:58 +00:00
# Verify .goreleaser.yml format first.
echo "Start to verify .goreleaser.yml format"
goreleaser check
2020-09-16 20:12:09 +00:00
# $PUBLISH must explicitly be set to 'TRUE' for goreleaser
2018-10-30 15:00:11 +00:00
# to publish the release to GitHub.
2020-09-16 20:12:09 +00:00
if [ [ " ${ PUBLISH :- } " != "TRUE" ] ] ; then
echo "Not set to publish"
2018-10-30 15:00:11 +00:00
goreleaser release \
2023-02-22 06:36:51 +00:00
--clean \
2018-10-30 15:00:11 +00:00
--release-notes= " ${ RELEASE_NOTES_FILE } " \
2023-04-11 08:27:58 +00:00
--snapshot # Generate an unversioned snapshot release, skipping all validations and without publishing any artifacts (implies --skip-publish, --skip-announce and --skip-validate)
2018-10-30 15:00:11 +00:00
else
2020-09-16 20:12:09 +00:00
echo "Getting ready to publish"
2018-10-30 15:00:11 +00:00
goreleaser release \
2023-02-22 06:36:51 +00:00
--clean \
2018-10-30 15:00:11 +00:00
--release-notes= " ${ RELEASE_NOTES_FILE } "
fi