Skip to content

Commit

Permalink
adds missing script
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
Adrian Cole committed Dec 31, 2023
1 parent c8e0020 commit 66e72a4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions build-bin/git/version_from_trigger_tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh
#
# Copyright 2023 The OpenZipkin Authors
#
# 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 echos a `MAJOR.MINOR.PATCH` version tag based on..
# * arg1: XXXXX- prefix
# * arg2: XXXXX-MAJOR.MINOR.PATCH git trigger tag
#
# The script exits 1 if the prefix doesn't match. On success, the tag is deleted if it exists.
#
# Note: In CI, `build-bin/git/login_git` must be called before invoking this.

set -ue

trigger_tag_prefix=${1?required. Ex docker- to match docker-1.2.3}
trigger_tag=${2?trigger_tag is required. Ex ${trigger_tag_prefix}1.2.3}

# Checking sed output to determine success as exit code handling in sed or awk is awkward
version=$(echo "${trigger_tag}" | sed -En "s/^${trigger_tag_prefix}([0-9]+\.[0-9]+\.[0-9]+)$/\1/p")

if [ -z "$version" ]; then
>&2 echo invalid trigger tag: ${trigger_tag}
exit 1;
fi

# try to cleanup the trigger tag if it exists, but don't fail if it doesn't
git tag -d ${trigger_tag} 2>&- >&- || true
git push origin :${trigger_tag} 2>&- >&- || true

echo $version

0 comments on commit 66e72a4

Please sign in to comment.