forked from cotes2020/jekyll-theme-chirpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump-version.sh
executable file
·53 lines (39 loc) · 1.12 KB
/
bump-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
#
# Bump latest version to file `_data/meta.yml`
#
# v2.5.1
# https://github.com/cotes2020/jekyll-theme-chirpy
# © 2020 Cotes Chung
# Published under MIT License
set -eu
META_FILE="_data/meta.yml"
bump() {
_version_field="version: $1"
if [[ ! -f $META_FILE ]]; then
echo "name: Chirpy" > $META_FILE
echo "$_version_field" >> $META_FILE
echo "homepage: https://github.com/cotes2020/jekyll-theme-chirpy/" >> $META_FILE
else
sed -i "s/^version:.*/$_version_field/g" $META_FILE
fi
if [[ -n $(git status $META_FILE -s) ]]; then
git add $META_FILE
git commit -m "Bump version to $1"
fi
}
_latest_tag="$(git describe --tags --abbrev=0)"
echo "Input a version number (hint: latest version is ${_latest_tag:1})"
read version
if [[ $version =~ ^[[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?$ ]]; then
if git tag --list | egrep -q "^v$version$"; then
echo "Error: version '$version' already exists"
exit -1
fi
echo "Bump version to $version"
bump "$version"
echo "Create tag v$version"
git tag "v$version"
else
echo "Error: Illegal version number: '$version'"
fi