Skip to content

Commit

Permalink
Shortened version var names
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed May 9, 2024
1 parent 01a5518 commit e64e6b9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions generate-ip/utils/bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,46 @@ bg="\033[1;92m" # bright green
bw="\033[1;97m" # bright white

# Validate version arg
version_types=("major" "minor" "patch")
if [[ ! "${version_types[@]}" =~ "$1" ]] ; then
ver_types=("major" "minor" "patch")
if [[ ! "${ver_types[@]}" =~ "$1" ]] ; then
echo "${br}Invalid version argument. Please specify 'major', 'minor', or 'patch'.${nc}"
exit 1 ; fi

# Determine new version to bump to
old_version=$(node -pe "require('./package.json').version")
IFS='.' read -ra subvers <<< "$old_version" # split old_version into subvers array
old_ver=$(node -pe "require('./package.json').version")
IFS='.' read -ra subvers <<< "$old_ver" # split old_ver into subvers array
case $1 in # edit subvers based on version type
"patch") subvers[2]=$((subvers[2] + 1)) ;;
"minor") subvers[1]=$((subvers[1] + 1)) ; subvers[2]=0 ;;
"major") subvers[0]=$((subvers[0] + 1)) ; subvers[1]=0 ; subvers[2]=0 ;;
esac
new_version=$(printf "%s.%s.%s" "${subvers[@]}")
new_ver=$(printf "%s.%s.%s" "${subvers[@]}")

# Bump version in package.json + package-lock.json
echo -e "${by}Bumping versions in package manifests...${bw}"
npm version --no-git-tag-version "$new_version"
npm version --no-git-tag-version "$new_ver"

# Bump versions in READMEs
echo -e "${by}\nBumping versions in READMEs...${bw}"
pkg_name=$(node -pe "require('./package.json').name" | sed -e 's/^@[a-zA-Z0-9-]*\///' -e 's/^@//')
sed_actions=(
# Latest Build shield link
-exec sed -i -E "s|(tag/[^0-9]+)[0-9]+\.[0-9]+\.[0-9]+|\1$new_version|g" {} +
-exec sed -i -E "s|(tag/[^0-9]+)[0-9]+\.[0-9]+\.[0-9]+|\1$new_ver|g" {} +
# Latest Build shield src
-exec sed -i -E "s|[0-9.]+(-.*logo=icinga)|$new_version\1|" {} +
-exec sed -i -E "s|[0-9.]+(-.*logo=icinga)|$new_ver\1|" {} +
# Minified Size shield link/src
-exec sed -i -E "s|-[0-9]+\.[0-9]+\.[0-9]+([^.]\|$)|-$new_version\1|g" {} +
-exec sed -i -E "s|-[0-9]+\.[0-9]+\.[0-9]+([^.]\|$)|-$new_ver\1|g" {} +
# jsDelivr ver tags in import section
-exec sed -i -E "s|@([0-9]+\.[0-9]+\.[0-9]+)|@$new_version|g" {} +
-exec sed -i -E "s|@([0-9]+\.[0-9]+\.[0-9]+)|@$new_ver|g" {} +
)
find . -name 'README.md' "${sed_actions[@]}"
echo "v$new_version"
echo "v$new_ver"

# Commit bumps to Git
echo -e "${by}\nCommitting bumps to Git...\n${nc}"
find . -name "README.md" -exec git add {} +
git add package*.json
git commit -n -m "Bumped $pkg_name versions to $new_version"
git commit -n -m "Bumped $pkg_name versions to $new_ver"

# Build minified JS to dist/
echo -e "${by}\nBuilding minified JS...\n${nc}"
Expand All @@ -72,7 +72,7 @@ fi
# Commit build to Git
echo -e "${by}\nCommitting build to Git...\n${nc}"
git add ./dist/*.js
git commit -n -m "Built $pkg_name v$new_version"
git commit -n -m "Built $pkg_name v$new_ver"

# Push all changes to GiHub
echo -e "${by}\nPushing to GitHub...\n${nc}"
Expand All @@ -84,6 +84,6 @@ if [[ "$*" == *"--publish"* ]] ; then
npm publish ; fi

# Print final summary
echo -e "\n${bg}Successfully bumped to v$new_version$(
echo -e "\n${bg}Successfully bumped to v$new_ver$(
[[ "$*" == *"--publish"* ]] && echo ' and published to npm' || echo ''
)!${nc}"

0 comments on commit e64e6b9

Please sign in to comment.