From 43641b0b9e7086f69ea4c1b4e44708defa88d464 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 20 May 2025 14:31:54 +0530 Subject: [PATCH] Add script to validate & create release tag --- auth/scripts/release_tag.sh | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 auth/scripts/release_tag.sh diff --git a/auth/scripts/release_tag.sh b/auth/scripts/release_tag.sh new file mode 100755 index 0000000000..fee85d2d74 --- /dev/null +++ b/auth/scripts/release_tag.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +#!/bin/bash + +# Function to display usage +usage() { + echo "Usage: $0 tag" + exit 1 +} + +# Ensure a tag was provided +[[ $# -eq 0 ]] && usage + +# Exit immediately if a command exits with a non-zero status +set -e + +# Go to the project root directory +cd "$(dirname "$0")/.." + +# Get the tag from the command line argument +TAG=$1 + + +# Get the version from the pubspec.yaml file and cut everything after the + +VERSION=$(grep "^version:" pubspec.yaml | awk '{ print $2 }' | cut -d '+' -f 1) + +PREFIX="auth-v" + +# Ensure the tag has the correct prefix +if [[ $TAG != $PREFIX* ]]; then + echo "Invalid tag. tags must start with '$PREFIX'." + exit 1 +fi + +# Ensure the tag version is in the pubspec.yaml file +if [[ $TAG != *$VERSION ]]; then + echo "Invalid tag." + echo "The version $VERSION in pubspec doesn't match the version in tag $TAG" + exit 1 +fi + +## If all checks pass, create the tag +git tag $TAG +echo "Tag $TAG created." + +exit 0