-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Souther
committed
Dec 3, 2024
1 parent
9c7a1d7
commit acc1ac7
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
|
||
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..." | ||
sed "/version/ s/$CURRENT/$VERSION/" package.json > package.json.out ; mv package.json.out package.json | ||
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 package.json | ||
git commit --message "Release ${VERSION}" | ||
|
||
if [ "$1" == "--release" ] ; then | ||
git tag "$VERSION" main | ||
git push "$REMOTE" "$VERSION" | ||
git push "$REMOTE" main | ||
fi |