-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bakefile.sh
49 lines (37 loc) · 1.49 KB
/
Bakefile.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
#!/usr/bin/env bash
# shellcheck disable=SC2155
# genrelease <{'revision','patch','minor','major'}> [push-tags]
task.genrelease() {
local tags="$(git tag --sort=version:refname)"
local tag_latest="$(tail -n 1 <<< "$tags")"
if [[ -z "$tag_latest" ]]; then
tag_latest="v0.0.0-1"
fi
tag_latest="${tag_latest#v}"
local type="${1-}" version_next
case "$type" in
revision) version_next="$(awk -F- '{$2++; print $1"-"$2}' <<< "$tag_latest")" ;;
patch) version_next="$(awk -F. '{$NF++; print $1"."$2"."$NF"-1"}' <<< "$tag_latest")" ;;
minor) version_next="$(awk -F. '{$2++; $3=0; print $1"."$2"."$3"-1"}' <<< "$tag_latest")" ;;
major) version_next="$(awk -F. '{$1++; $2=0; $3=0; print $1"."$2"."$3"-1"}' <<< "$tag_latest")" ;;
*) bake.die "expected 'revision', 'patch', 'minor', 'major'. got '$type'" ;;
esac
./luarocks lint ./warna-dev-1.rockspec
rockspec="$(< ./warna-dev-1.rockspec)"
rockspec="${rockspec//local _version/local _version = \"$version_next\"}"
echo "$rockspec" > "warna-$version_next.rockspec"
mkdir -p out
rockspec="$(< ./warna-tl-dev-1.rockspec)"
rockspec="${rockspec//local _version/local _version = \"$version_next\"}"
echo "$rockspec" > "warna-tl-$version_next.rockspec"
git tag -a "v$version_next" -m "Release: v$version_next"
[[ -n "$2" ]] && git push origin main --follow-tags
return 0
}
# format
task.format() {
stylua . ./*.rockspec
while read -r f; do
shfmt -w "$f"
done < <(find . -name '*.sh' -not -path 'lua_modules')
}