hack: fix release scripts (#157)

Previous release script wasn't committing/tagging in the right order.
Also made scripts resistant to:
* empty env vars
* current workdir the script is invoked from

cc: @m-okeefe
This commit is contained in:
Ahmet Alp Balkan 2019-02-20 11:07:26 -08:00 committed by GitHub
parent cedf3ce827
commit f3e29f7450
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 12 deletions

View file

@ -21,8 +21,8 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
log() { echo "$1" >&2; } log() { echo "$1" >&2; }
TAG="${TAG?TAG env variable must be specified}" TAG="${TAG:?TAG env variable must be specified}"
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}" REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}"
while IFS= read -d $'\0' -r dir; do while IFS= read -d $'\0' -r dir; do
# build image # build image

View file

@ -23,8 +23,8 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
log() { echo "$1" >&2; } log() { echo "$1" >&2; }
TAG="${TAG?TAG env variable must be specified}" TAG="${TAG:?TAG env variable must be specified}"
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}" REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}"
OUT_DIR="${OUT_DIR:-${SCRIPTDIR}/../release}" OUT_DIR="${OUT_DIR:-${SCRIPTDIR}/../release}"
read_manifests() { read_manifests() {

View file

@ -14,28 +14,37 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# Creates a new release by 1) building/pushing images, 2) injecting tag into YAML, # This script creates a new release by:
# 3) creating a new git tag, and 4) pushing tags/updated YAML to $BRANCH. # - 1. building/pushing images
# - 2. injecting tags into YAML manifests
# - 3. creating a new git tag
# - 4. pushing the tag/commit to master.
set -euo pipefail set -euo pipefail
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[[ -n "${DEBUG:-}" ]] && set -x
log() { echo "$1" >&2; } log() { echo "$1" >&2; }
fail() { log "$1"; exit 1; } fail() { log "$1"; exit 1; }
TAG="${TAG?TAG env variable must be specified}" TAG="${TAG:?TAG env variable must be specified}"
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}" REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified e.g. gcr.io\/google-samples\/microservices-demo}"
if [[ "$TAG" != v* ]]; then
fail "\$TAG must start with 'v', e.g. v0.1.0 (got: $TAG)"
fi
# build and push images # build and push images
./hack/make-docker-images.sh "${SCRIPTDIR}"/make-docker-images.sh
# update yaml # update yaml
./hack/make-release-artifacts.sh "${SCRIPTDIR}"/make-release-artifacts.sh
# create git release / push to master # create git release / push to master
git add "${SCRIPTDIR}/../release/"
git commit --allow-empty -m "Release $TAG"
log "Pushing k8s manifests to master..." log "Pushing k8s manifests to master..."
git tag "$TAG" git tag "$TAG"
git add release/
git commit --allow-empty -m "Release $TAG"
git push --tags git push --tags
git push origin master git push origin master