Skip to content

Commit a3331ee

Browse files
committed
Added check commit for changes pre-bump ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions]
1 parent 10f0d4f commit a3331ee

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

utils/bump.sh

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22

3-
# Bumps extension manifest + git commit/push
3+
# Bumps Chromium extension manifest + git commit/push
4+
5+
shopt -s nocasematch # enable case-insensitive matching (to flexibly check commit msg for bumps)
46

57
# Init UI COLORS
68
NC="\033[0m" # no color
@@ -10,32 +12,42 @@ BG="\033[1;92m" # bright green
1012
BW="\033[1;97m" # bright white
1113

1214
# Init manifest PATH
13-
manifest_path="chromium/extension/manifest.json"
15+
MANIFEST_PATH="chromium/extension/manifest.json"
16+
17+
echo -e "${BY}\nBumping version in ${MANIFEST_PATH}...${NC}\n"
1418

15-
# BUMP version
16-
echo -e "${BY}\nBumping version in ${manifest}...${NC}\n"
19+
# Init BUMP vars
1720
bumped_cnt=0
1821
TODAY=$(date +'%Y.%-m.%-d') # YYYY.M.D format
19-
new_versions=() # for dynamic commit msg
20-
old_ver=$(sed -n 's/.*"version": *"\([0-9.]*\)".*/\1/p' "$manifest")
22+
23+
# Check latest commit for extension changes
24+
chromium_manifest_path=$(dirname "$MANIFEST_PATH" | sed 's|^\./||')
25+
echo "Checking last commit details for $chromium_manifest_path..."
26+
latest_platform_commit_msg=$(git log -1 --format=%s -- "$chromium_manifest_path")
27+
if [[ $latest_platform_commit_msg == bump*(version|manifest)* ]] ; then
28+
echo -e "No changes found." ; exit ; fi
29+
30+
echo "Bumping version in Chromium manifest..."
31+
32+
# Determine old/new versions
33+
old_ver=$(sed -n 's/.*"version": *"\([0-9.]*\)".*/\1/p' "$MANIFEST_PATH")
2134
if [[ $old_ver == "$TODAY" ]] ; then
2235
new_ver="$TODAY.1"
2336
elif [[ $old_ver == "$TODAY."* ]] ; then
2437
LAST_NUMBER=$(echo "$old_ver" | awk -F '.' '{print $NF}')
2538
new_ver="$TODAY.$((LAST_NUMBER + 1))"
2639
else new_ver="$TODAY" ; fi
27-
new_versions+=("$new_ver")
28-
sed -i "s/\"version\": \"$old_ver\"/\"version\": \"$new_ver\"/" "$manifest_path"
29-
echo -e "Updated: ${BW}v${old_ver}${NC}${BG}v${NEW_VER}${NC}"
40+
41+
# Bump old version
42+
sed -i "s/\"version\": \"$old_ver\"/\"version\": \"$new_ver\"/" "$MANIFEST_PATH"
43+
echo -e "Updated: ${BW}v${old_ver}${NC}${BG}v${new_ver}${NC}\n"
3044
((bumped_cnt++))
3145

32-
# COMMIT/PUSH bump
46+
# COMMIT/PUSH bump(s)
3347
if [[ $bumped_cnt -eq 0 ]] ; then echo -e "${BW}Completed. No manifests bumped.${NC}"
3448
else
35-
echo -e "\n${BY}\nCommitting bump to Git...\n${NC}"
36-
git add ./**/manifest.json && git commit -n -m "Bumped \`version\` to $NEW_VER"
37-
git push
38-
39-
# Print FINAL summary
40-
echo -e "\n${BG}Success! ${manifest} updated/committed/pushed to GitHub${NC}"
49+
echo -e "${BY}Committing bump to Git...${NC}"
50+
#git add ./**/manifest.json && git commit -n -m "Bumped \`version\` to $NEW_VER"
51+
#git push
52+
echo -e "\n${BG}Success! Manifest updated/committed/pushed to GitHub${NC}"
4153
fi

0 commit comments

Comments
 (0)