|
| 1 | +#!/bin/bash -eu |
| 2 | +# |
| 3 | +# Copyright 2018 Google LLC |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# Usage: |
| 18 | +# (1) Update version in manifest.json |
| 19 | +# (2) Run release.sh |
| 20 | + |
| 21 | +cd $(dirname $0) |
| 22 | + |
| 23 | +function die() { |
| 24 | + echo $1 |
| 25 | + exit 1 |
| 26 | +} |
| 27 | + |
| 28 | +# Read current version from manifest. |
| 29 | +readonly MANIFEST=${PWD}/manifest.json |
| 30 | +readonly VERSION=$(cat "${MANIFEST}" | python -c "import sys, json; print json.load(sys.stdin)['version']") |
| 31 | +readonly TAG=v${VERSION} |
| 32 | + |
| 33 | +# Ensure the tag doesn't already exist. This could happen if someone forgot to |
| 34 | +# update the version in manifest.json. |
| 35 | +test -z $(git tag | grep --line-regexp "${TAG}") \ |
| 36 | + || die "Version ${VERSION} already exists" |
| 37 | + |
| 38 | +# Update all vendor packages and ensure everything still builds |
| 39 | +# and tests pass. |
| 40 | +govendor fetch +vendor |
| 41 | +make |
| 42 | + |
| 43 | +# Commit everything. This should include the change to manifest.json and any |
| 44 | +# updated vendored packages. |
| 45 | +git add . |
| 46 | +git commit -m "Bump to version ${VERSION}" |
| 47 | + |
| 48 | +# Tag the release. |
| 49 | +git tag -a "${TAG}" -m "Tag version ${VERSION}" |
| 50 | + |
| 51 | +# Push to remote repository, both changes and tags. |
| 52 | +git push |
| 53 | +git push --tags |
0 commit comments