Skip to content

Commit a91e3c3

Browse files
authored
Merge pull request #4504 from unisonweb/version-numbers
2 parents 309517c + 5f7a625 commit a91e3c3

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
workflow_dispatch:
1111
inputs:
1212
version:
13-
description: 'Release Version (E.g. M4 or M4a)'
13+
description: 'Release Version (E.g. M4 or M4a or 0.4.1)'
1414
required: true
1515
type: string
1616
target:

scripts/make-release.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ usage() {
1717
echo ""
1818
echo "E.g."
1919
echo "$0 M4a"
20+
echo ""
21+
echo "The latest release is: $(git tag --list 'release/*' | sort -r | head -n 1 | sed 's/release\///')"
2022
}
2123

2224
if [[ -z "$1" ]] ; then
@@ -29,8 +31,8 @@ if ! command -V "gh" >/dev/null 2>&1; then
2931
exit 1
3032
fi
3133

32-
if ! [[ "$1" =~ ^M[0-9]+[a-z]?$ ]] ; then
33-
echo "Version tag must be of the form 'M4' or 'M4a'"
34+
if ! [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then
35+
echo "Version tag must be of the form 'x.y.z' where x, y, and z are nonnegative integers."
3436
usage
3537
exit 1
3638
fi

scripts/previous-tag.sh

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,34 @@ if ! ("$awk_exe" --version | grep GNU) >/dev/null 2>&1; then
1717
exit 1
1818
fi
1919

20-
if ! [[ "$1" =~ ^M[0-9]+[a-z]?$ ]] ; then
21-
echo "Version tag must be of the form 'M4' or 'M4a'. E.g."
22-
echo "$0 M4a"
20+
input_version="$1"
21+
22+
if ! [[ "$input_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then
23+
echo "Version tag must be of the form 'x.y.z' where x, y, and z are nonnegative integers. e.g."
24+
echo "$0 0.5.11"
2325
exit 1
2426
fi
2527

26-
echo "$1" | $awk_exe '
27-
# This script figures out a previous tag for a given release to make release notes from.
28+
if [[ "$input_version" == "0.5.11" ]]; then
29+
echo "M5j"
30+
else
31+
IFS='.' read -r -a version_parts <<< "$input_version"
32+
major=${version_parts[0]}
33+
minor=${version_parts[1]}
34+
patch=${version_parts[2]}
2835

29-
# The previous release of something like M4a is just M4
30-
match($0, /^(\w[0-9]+)a$/, a) {print a[1]}
31-
# The previous release of something like M4 is M3, since we want to show off everything since the last major release
32-
match($0, /^\w([0-9]+)$/, a) {print "M" a[1] - 1}
33-
# The previous release of something like M4b is M4a
34-
match($0, /^(\w[0-9]+)([b-z])$/, a) {printf a[1]; system("echo " a[2] " | tr b-z a-y")}
35-
'
36+
if [[ "$patch" -gt 0 ]]; then
37+
patch=$((patch - 1))
38+
echo "$major.$minor.$patch"
39+
elif [[ "$minor" -gt 0 ]]; then
40+
minor=$((minor - 1))
41+
tag=$(git tag --list "release/$major.$minor.*" | sort -r | head -n 1)
42+
echo "${tag#release/}"
43+
elif [[ "$major" -gt 0 ]]; then
44+
major=$((major - 1))
45+
tag=$(git tag --list "release/$major.*" | sort -r | head -n 1)
46+
echo "${tag#release/}"
47+
else
48+
echo "Idk what to do with $input_version".
49+
fi
50+
fi

0 commit comments

Comments
 (0)