Skip to content

Commit

Permalink
hack: fix release scripts (GoogleCloudPlatform#157)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ahmetb authored Feb 20, 2019
1 parent cedf3ce commit f3e29f7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions hack/make-docker-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

log() { echo "$1" >&2; }

TAG="${TAG?TAG env variable must be specified}"
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}"
TAG="${TAG:?TAG env variable must be specified}"
REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}"

while IFS= read -d $'\0' -r dir; do
# build image
Expand Down
4 changes: 2 additions & 2 deletions hack/make-release-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

log() { echo "$1" >&2; }

TAG="${TAG?TAG env variable must be specified}"
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}"
TAG="${TAG:?TAG env variable must be specified}"
REPO_PREFIX="${REPO_PREFIX:?REPO_PREFIX env variable must be specified}"
OUT_DIR="${OUT_DIR:-${SCRIPTDIR}/../release}"

read_manifests() {
Expand Down
25 changes: 17 additions & 8 deletions hack/make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,37 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Creates a new release by 1) building/pushing images, 2) injecting tag into YAML,
# 3) creating a new git tag, and 4) pushing tags/updated YAML to $BRANCH.
# This script creates a new release by:
# - 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
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
[[ -n "${DEBUG:-}" ]] && set -x

log() { echo "$1" >&2; }
fail() { log "$1"; exit 1; }

TAG="${TAG?TAG env variable must be specified}"
REPO_PREFIX="${REPO_PREFIX?REPO_PREFIX env variable must be specified}"
TAG="${TAG:?TAG 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
./hack/make-docker-images.sh
"${SCRIPTDIR}"/make-docker-images.sh

# update yaml
./hack/make-release-artifacts.sh
"${SCRIPTDIR}"/make-release-artifacts.sh

# create git release / push to master
git add "${SCRIPTDIR}/../release/"
git commit --allow-empty -m "Release $TAG"
log "Pushing k8s manifests to master..."
git tag "$TAG"
git add release/
git commit --allow-empty -m "Release $TAG"
git push --tags
git push origin master

Expand Down

0 comments on commit f3e29f7

Please sign in to comment.