mirror of https://github.com/linkerd/linkerd2.git
101 lines
2.8 KiB
Bash
Executable File
101 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
|
|
# Assert at least one and at most two arguments were passed.
|
|
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
|
echo "Error: ${0##*/} accepts 1 or 2 arguments" >&2
|
|
echo "Usage:" >&2
|
|
echo " ${0##*/} edge" >&2
|
|
echo " ${0##*/} stable x.x.x" >&2
|
|
exit 1
|
|
fi
|
|
|
|
release_channel="$1"
|
|
|
|
# Verify the release channel.
|
|
release_channel_regex="^(edge|stable)$"
|
|
if [[ ! $release_channel =~ $release_channel_regex ]]; then
|
|
echo "Error: valid release channels: edge, stable"
|
|
echo "Usage:"
|
|
echo " bin/create-release-tag edge"
|
|
echo " bin/create-release-tag stable 2.4.8"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$release_channel" == "stable" ]; then
|
|
if [ $# -ne 2 ]; then
|
|
echo "Error: accepts 2 arguments"
|
|
echo "Usage:"
|
|
echo " bin/create-release-tag stable 2.4.8"
|
|
exit 1
|
|
fi
|
|
|
|
stable_tag="$2"
|
|
|
|
# Verify the stable tag format.
|
|
stable_tag_regex="^([0-9]+)\.([0-9]+)\.([0-9]+)$"
|
|
if [[ ! $stable_tag =~ $stable_tag_regex ]]; then
|
|
echo "Error: version reference incorrect"
|
|
echo "Usage:"
|
|
echo " bin/create-release-tag stable 2.4.8"
|
|
exit 1
|
|
fi
|
|
|
|
# Set the script global `release_tag` variable.
|
|
release_tag="stable-$stable_tag"
|
|
fi
|
|
|
|
if [ "$release_channel" == "edge" ]; then
|
|
if [ $# -ne 1 ]; then
|
|
echo "Error: accepts 1 argument"
|
|
echo "Usage:"
|
|
echo " bin/create-release-tag edge"
|
|
exit 1
|
|
fi
|
|
|
|
# Some awks on Linux do no support quantifiers in regex, so this regex is
|
|
# explicit.
|
|
edge_tag_regex="(edge)-([0-9][0-9])\.([0-9]|[0-9][0-9])\.([0-9]+)"
|
|
url="https://run.linkerd.io/install-edge"
|
|
|
|
# Get the current edge version.
|
|
current_edge=$(curl -sL $url | awk -v tag_format="$edge_tag_regex" '$0 ~ tag_format')
|
|
|
|
# Get the third and fourth groups of the regex; they are the month and
|
|
# month minor values for the current edge version.
|
|
current_mm=$(echo "$current_edge" | sed -n -E "s/.*$edge_tag_regex}$/\3/p")
|
|
current_xx=$(echo "$current_edge" | sed -n -E "s/.*$edge_tag_regex}$/\4/p")
|
|
|
|
yy=$(date +"%y")
|
|
|
|
# Strip leading zero
|
|
new_mm=$(date +"%-m")
|
|
|
|
# If this is a new month, `new_xx` should be 1; otherwise increment it.
|
|
if [ ! "$new_mm" == "$current_mm" ]; then
|
|
new_xx="1"
|
|
else
|
|
new_xx=$((current_xx+1))
|
|
fi
|
|
|
|
# Set the script global `release_tag` variable.
|
|
release_tag="edge-$yy.$new_mm.$new_xx"
|
|
fi
|
|
|
|
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
|
|
# shellcheck source=bin/_release.sh
|
|
tmp=$(. "$bindir"/_release.sh; extract_release_notes)
|
|
|
|
# Create a signed tag with the commit message.
|
|
git tag -s -F "$tmp" "$release_tag"
|
|
|
|
# Success message
|
|
echo "$release_tag tag created and signed."
|
|
echo ""
|
|
echo "tag: $release_tag"
|
|
echo ""
|
|
echo "To push tag, run:"
|
|
echo " git push origin $release_tag"
|