forked from nand2tetris/web-ide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stamp.sh
executable file
·36 lines (32 loc) · 1.23 KB
/
stamp.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
#!/usr/bin/bash
set -e # Exit on errors
set -x # Shell debugging
# CURRENT and NEXT have the format YYYY.WW.REV, where YYYY is the current year,
# WW is the current week, and REV is the number of releases this week.
# The next revision compares the two, in this way
# - If NEXT is later than CURRENT in any fields, accept NEXT.
# - Otherwise, return CURRENT, with one added to REV.
#
# THIS FUNCTION IS NOT TRANSITIVE! It must be called with
# `compare_versions CURRENT NEXT`
compare_versions() {
if [[ "$1" < "$2" ]]; then
echo "$2"
else
IFS='.' read -r y1 w1 r1 <<<"$1"
r1=$((r1 + 1))
echo "${y1}.${w1}.${r1}"
fi
}
# compare_versions 2024.44.4 2024.44.0 # 2024.44.5
# compare_versions 2024.44.4 2024.45.0 # 2024.45.0
# compare_versions 2024.44.4 2025.1.0 # 2025.1.0
CURRENT=$(grep version package.json | awk -F\" '{print $4}')
NEXT=$(date +%Y.%W.0)
VERSION=$(compare_versions "$CURRENT" "$NEXT")
echo "Releasing $VERSION..."
npm version "$VERSION" --include-workspace-root --no-git-tag-version
sed "/version/ s/$CURRENT/$VERSION/" web/public/index.html > web/public/index.html.out ; mv web/public/index.html.out web/public/index.html
git --no-pager diff
git add .
git commit --message "Release ${VERSION}"