File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -eu -o pipefail
3
+
4
+ function usage() {
5
+ echo " Usage: release.sh [-h] semver" 1>&2
6
+ echo " -h Show help" 1>&2
7
+ echo " Example: release.sh 0.2.7" 1>&2
8
+ }
9
+
10
+ SEMVER_REGEX=" ^(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)\\ .(0|[1-9][0-9]*)(\\ -[0-9A-Za-z-]+(\\ .[0-9A-Za-z-]+)*)?(\\ +[0-9A-Za-z-]+(\\ .[0-9A-Za-z-]+)*)?$"
11
+ function validate_version {
12
+ local version=$1
13
+ if ! [[ " $version " =~ $SEMVER_REGEX ]]; then
14
+ echo " version $version does not match the semver scheme 'X.Y.Z(-PRERELEASE)(+BUILD)'. See help for more information." 1>&2
15
+ exit 1
16
+ fi
17
+ }
18
+
19
+ while getopts " h" arg; do
20
+ case $arg in
21
+ h|* ) # Show help
22
+ usage
23
+ exit 1
24
+ ;;
25
+ esac
26
+ done
27
+
28
+ version=" ${1-} "
29
+ if [ -z " $version " ]; then
30
+ usage
31
+ exit 1
32
+ fi
33
+
34
+ validate_version " $version "
35
+
36
+ git commit --allow-empty --message=" Release v$version "
37
+ git tag " v$version "
38
+ git push
39
+ git push --tags
You can’t perform that action at this time.
0 commit comments