Skip to content

Commit

Permalink
feat: add --new option on build.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Sep 18, 2024
1 parent e524de9 commit f9c3ac9
Show file tree
Hide file tree
Showing 3 changed files with 497 additions and 1 deletion.
50 changes: 49 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,58 @@ function generate_checksum() {
echo "$checksum"
}

function update_version() {
local version_type=$1
local version_file=$2

local current_version
current_version=$(cat "$version_file")
IFS='.' read -r major minor patch <<< "$current_version"

case "$version_type" in
major)
major=$((major + 1))
;;
minor)
minor=$((minor + 1))
;;
patch)
patch=$((patch + 1))
;;
*)
echo "Invalid version increment option: $version_type. Use major, minor, or patch."
exit 1
;;
esac

local new_version="$major.$minor.$patch"
echo "$new_version" > "$version_file"
echo "Version updated to $new_version"
}

########################
# MAIN #
########################
OUT_DIR=${1:-"bin"}
OUT_DIR="bin"
NEW_VERSION_TYPE=""

# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--new)
shift
NEW_VERSION_TYPE="$1"
;;
*)
OUT_DIR="$1"
;;
esac
shift
done

if [[ "$NEW_VERSION_TYPE" != "" ]]; then
update_version "$NEW_VERSION_TYPE" "src/version.txt"
fi

mkdir -p "$OUT_DIR"
build "$OUT_DIR/deploy"
1 change: 1 addition & 0 deletions local/checksum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f972bf56d22d59324bbf66e34840313fab66fde3b75a4350a42a5987ce020676 local/deploy
Loading

0 comments on commit f9c3ac9

Please sign in to comment.