@@ -11,18 +11,43 @@ set -eu
1111
1212META_FILE=" _data/meta.yml"
1313
14- _latest_tag=" $( git describe --abbrev=0) "
14+ bump () {
15+ _version_field=" version: $1 "
1516
16- _version_field=" version: $_latest_tag "
17+ if [[ ! -f $META_FILE ]]; then
18+ echo " name: Chirpy" > $META_FILE
19+ echo " $_version_field " >> $META_FILE
20+ echo " homepage: https://github.com/cotes2020/jekyll-theme-chirpy/" >> $META_FILE
21+ else
22+ sed -i " s/^version:.*/$_version_field /g" $META_FILE
23+ fi
24+
25+ if [[ -n $( git status $META_FILE -s) ]]; then
26+ git add $META_FILE
27+ git commit -m " Bump version to $1 "
28+ fi
29+ }
30+
31+ _latest_tag=" $( git describe --tags --abbrev=0) "
32+
33+ echo " Input a version number (hint: latest version is ${_latest_tag: 1} )"
34+
35+ read version
36+
37+ if [[ $version =~ ^[[:digit:]]+\. [[:digit:]]+ (\. [[:digit:]]+)? $ ]]; then
38+
39+ if git tag --list | egrep -q " ^v$version $" ; then
40+ echo " Error: version '$version ' already exists"
41+ exit -1
42+ fi
43+
44+ echo " Bump version to $version "
45+ bump " $version "
46+
47+ echo " Create tag v$version "
48+ git tag " v$version "
1749
18- if [[ ! -f $META_FILE ]]; then
19- echo " name: Chirpy" > $META_FILE
20- echo " $_version_field " >> $META_FILE
2150else
22- sed -i " s/^version:.*/$_version_field /g" $META_FILE
23- fi
2451
25- if [[ -n $( git status $META_FILE -s) ]]; then
26- git add $META_FILE
27- git commit -m " Bump version to $_latest_tag "
52+ echo " Error: Illegal version number: '$version '"
2853fi
0 commit comments