summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2019-04-01 16:17:40 -0700
committerShentubot <shentubot@google.com>2019-04-01 16:18:43 -0700
commit7543e9ec2043af7d071373aeec04b92a98051087 (patch)
treef43044f892c853d5cf97fe5d12f6d6702a2a02f1 /tools
parent7cff746ef2bbe5351e5985bebc88efc9e0881c78 (diff)
Add release hook and version flag
PiperOrigin-RevId: 241421671 Change-Id: Ic0cebfe3efd458dc42c49f7f812c13318705199a
Diffstat (limited to 'tools')
-rwxr-xr-xtools/tag_release.sh53
-rwxr-xr-xtools/workspace_status.sh2
2 files changed, 54 insertions, 1 deletions
diff --git a/tools/tag_release.sh b/tools/tag_release.sh
new file mode 100755
index 000000000..6906a952f
--- /dev/null
+++ b/tools/tag_release.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Copyright 2019 Google LLC
+#
+# 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.
+
+# This script will optionally map a PiperOrigin-RevId to a given commit,
+# validate a provided release name, create a tag and push it. It must be
+# run manually when a release is created.
+
+set -euxo pipefail
+
+# Check arguments.
+if [ "$#" -ne 2 ]; then
+ echo "usage: $0 <commit|revid> <release.rc>"
+ exit 1
+fi
+
+commit=$1
+release=$2
+
+# Is the passed identifier a sha commit?
+if ! git show "${commit}" &> /dev/null; then
+ # Extract the commit given a piper ID.
+ commit=$(git log|grep -E "(^commit |^ PiperOrigin-RevId:)" |grep -B1 "RevId: ${commit}"| head -n1|cut -d" " -f2)
+fi
+if ! git show "${commit}" &> /dev/null; then
+ echo "unknown commit: ${commit}"
+ exit 1
+fi
+
+# Is the release name sane? Must be a date with patch/rc.
+if ! [[ "${release}" =~ ^20[0-9]{6}\.[0-9]+$ ]]; then
+ expected=$(date +%Y%m%d.0) # Use today's date.
+ echo "unexpected release format: ${release}"
+ echo " ... expected like ${expected}"
+ exit 1
+fi
+
+# Tag the given commit.
+tag="release-${release}"
+(git tag "${tag}" "${commit}" && git push origin tag "${tag}") || \
+ (git tag -d "${tag}" && false)
diff --git a/tools/workspace_status.sh b/tools/workspace_status.sh
index 7d44dad37..a0e646e45 100755
--- a/tools/workspace_status.sh
+++ b/tools/workspace_status.sh
@@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-echo GIT_REVISION $(git describe --always --abbrev=40 --dirty)
+echo VERSION $(git describe --always --tags --abbrev=12 --dirty)