Skip to content

Commit 9a35a57

Browse files
committed
add tagging scripts
1 parent 4ef6edf commit 9a35a57

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

buildScript/next-pre-tag.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
#
3+
# Tag repository with the next pre tag
4+
#
5+
6+
currBranchLine=$(git status | head -1)
7+
cbAsArray=($currBranchLine)
8+
branch=${cbAsArray[2]}
9+
baseVer='unknown'
10+
#
11+
# Determine the branch, and the version to use for the next tag
12+
# User must be on a rc or dev branch, otherwise exist
13+
#
14+
if [ "$branch" = "dev" ]; then
15+
cycle=$(git describe --tags --match 'cycle-*' --abbrev=0)
16+
baseVer=$(echo $cycle | sed 's/cycle-//')
17+
else
18+
if [[ "$branch" =~ rc- ]]; then
19+
baseVer=$(echo $branch | sed 's/rc-//')
20+
else
21+
echo "Exiting: You must be on a rc or dev branch"
22+
exit
23+
fi
24+
fi
25+
26+
#
27+
# get a list of all the previous pre tags and the determine the next number to use
28+
#
29+
matchingPreTags=($(git tag | grep 'pre-.*'${baseVer}))
30+
31+
if [ -z "${matchingPreTags[0]}" ]; then
32+
nextNum=1
33+
else
34+
for aTag in "${matchingPreTags[@]}"; do
35+
asNum=$(echo $aTag $| sed 's/pre-//' | sed 's/-.*$//')
36+
number_array+=("$asNum")
37+
done
38+
sorted_array=($(printf "%s\n" "${number_array[@]}" | sort -n -r))
39+
nextNum=$(expr ${sorted_array[0]} + 1)
40+
fi
41+
42+
#
43+
# build the new tag string and then "git tag" and "git push --tags"
44+
#
45+
newPreTag=pre-${nextNum}-${baseVer}
46+
read -n1 -s -p "New ($branch branch) tag will be: $newPreTag, make tag? (y/n [y]): " makeTag
47+
echo
48+
makeTagLower=$(echo "$makeTag" | tr '[:upper:]' '[:lower:]')
49+
if [ "$makeTagLower" = "y" ] || [ "$makeTagLower" = "" ]; then
50+
echo '>>>>>' git tag $newPreTag
51+
git tag $newPreTag
52+
read -n1 -s -p "push tags (y/n [n]): " doPush
53+
doPushLower=$(echo "$doPush" | tr '[:upper:]' '[:lower:]')
54+
echo
55+
if [ "$doPushLower" = "y" ]; then
56+
echo '>>>>>' git push origin --tags
57+
git push origin --tags
58+
else
59+
echo not pushing
60+
fi
61+
else
62+
echo not taging
63+
fi

buildScript/next-release-tag.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
#
3+
# Tag repository with the next release tag, you must be on a rc branch
4+
#
5+
6+
currBranchLine=$(git status | head -1)
7+
cbAsArray=($currBranchLine)
8+
branch=${cbAsArray[2]}
9+
baseVer='unknown'
10+
#
11+
# Determine the branch, and the version to use for the next tag
12+
# User must be on a rc or dev branch, otherwise exist
13+
#
14+
if [[ "$branch" =~ rc- ]]; then
15+
baseVer=$(echo $branch | sed 's/rc-//')
16+
else
17+
echo "Exiting: You must be on a rc branch"
18+
exit
19+
fi
20+
21+
#
22+
# get a list of all the previous release tags and the determine the next number to use
23+
#
24+
matchingReleaseTags=($(git tag | grep 'release-.*'${baseVer}))
25+
26+
if [ -z "${matchingReleaseTags[0]}" ]; then
27+
nextRev=0
28+
else
29+
for aTag in "${matchingReleaseTags[@]}"; do
30+
sedStr="s/release-${baseVer}.//"
31+
echo aTag $aTag
32+
asNum=$(echo $aTag | sed $sedStr)
33+
number_array+=("$asNum")
34+
done
35+
sorted_array=($(printf "%s\n" "${number_array[@]}" | sort -n -r))
36+
nextRev=$(expr ${sorted_array[0]} + 1)
37+
fi
38+
39+
#
40+
# build the new tag string and then "git tag" and "git push --tags"
41+
#
42+
newReleaseTag=release-${baseVer}.${nextRev}
43+
read -n1 -s -p "New ($branch branch) tag will be: $newReleaseTag, make tag? (y/n [y]): " makeTag
44+
echo
45+
makeTagLower=$(echo "$makeTag" | tr '[:upper:]' '[:lower:]')
46+
if [ "$makeTagLower" = "y" ] || [ "$makeTagLower" = "" ]; then
47+
echo '>>>>>' git tag $newReleaseTag
48+
git tag $newReleaseTag
49+
read -n1 -s -p "push tags (y/n [n]): " doPush
50+
doPushLower=$(echo "$doPush" | tr '[:upper:]' '[:lower:]')
51+
echo
52+
if [ "$doPushLower" = "y" ]; then
53+
echo '>>>>>' git push origin --tags
54+
git push origin --tags
55+
else
56+
echo not pushing
57+
fi
58+
else
59+
echo not taging
60+
fi

0 commit comments

Comments
 (0)