Skip to content

Commit f0b9150

Browse files
committed
Improve the bump version tool
1 parent b11ba84 commit f0b9150

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

_includes/head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<head>
1010
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
1111
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
12-
<meta name="theme" content="{{ site.data.meta.name }} {{ site.data.meta.version }}">
12+
<meta name="theme" content="{{ site.data.meta.name }} v{{ site.data.meta.version }}">
1313

1414
{% seo title=false %}
1515

tools/bump-version.sh

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,43 @@ set -eu
1111

1212
META_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
2150
else
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'"
2853
fi

0 commit comments

Comments
 (0)