Skip to content

Commit

Permalink
build script to automate building process
Browse files Browse the repository at this point in the history
  • Loading branch information
Trsnaqe committed Dec 26, 2024
1 parent 5f640c7 commit f3fd63f
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 15 deletions.
94 changes: 94 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

if ! command -v jq &> /dev/null; then
echo "Error: jq is required but not installed."
echo "Install it using:"
echo " Ubuntu/Debian: sudo apt-get install jq"
echo " MacOS: brew install jq"
exit 1
fi

increment_version() {
local version=$1
local type=$2

IFS='.' read -r -a parts <<< "$version"
local major="${parts[0]}"
local minor="${parts[1]}"
local patch="${parts[2]}"

if [ "$type" == "--major" ]; then
if [ "$minor" == "9" ]; then
major=$((major + 1))
minor=0
patch=0
else
minor=$((minor + 4))
patch=0
fi
else
if [ "$patch" == "99" ]; then
minor=$((minor + 1))
patch=0
else
patch=$((patch + 1))
fi
fi

echo "$major.$minor.$patch"
}

update_html_files() {
local old_version=$1
local new_version=$2
local files=("src/pages/choose-currency.html" "src/pages/index.html")

for file in "${files[@]}"; do
if [ ! -f "$file" ]; then
echo "Warning: $file not found"
continue
fi

temp_file="$file.tmp"

while IFS= read -r line; do
if echo "$line" | grep -q "version-text"; then
line=$(echo "$line" | sed -E "s/v$old_version/v$new_version/g")
fi
echo "$line" >> "$temp_file"
done < "$file"

mv "$temp_file" "$file"
done
}

build_type="--minor"
if [ "$#" -eq 1 ] && [ "$1" == "--major" ]; then
build_type="--major"
fi

current_version=$(jq -r '.version' manifest.json)
new_version=$(increment_version "$current_version" "$build_type")

jq ".version = \"$new_version\"" manifest.json > manifest.json.tmp && mv manifest.json.tmp manifest.json
jq ".version = \"$new_version\"" manifest_firefox.json > manifest_firefox.json.tmp && mv manifest_firefox.json.tmp manifest_firefox.json

update_html_files "$current_version" "$new_version"

rm -f Steam-Currency-Converter-Chrome-V*.zip
zip -r "Steam-Currency-Converter-Chrome-V${new_version}.zip" . \
-x "*.git*" ".git/*" "*.zip" ".vscode/*" "manifest_firefox.json" "build.sh" "node_modules/*"

rm -f Steam-Currency-Converter-Firefox-V*.zip
cp manifest_firefox.json manifest_firefox_temp.json
mv manifest.json manifest_temp.json
mv manifest_firefox_temp.json manifest.json

zip -r "Steam-Currency-Converter-Firefox-V${new_version}.zip" . \
-x "*.git*" ".git/*" "*.zip" ".vscode/*" "manifest_firefox.json" "build.sh" "node_modules/*"

mv manifest_temp.json manifest.json

echo "Version updated from $current_version to $new_version"
echo "Created Steam-Currency-Converter-Chrome-V${new_version}.zip"
echo "Created Steam-Currency-Converter-Firefox-V${new_version}.zip"
28 changes: 20 additions & 8 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"name": "Steam Currency Converter",
"description": "Seamlessly Convert Steam Prices to Local Currency!",
"version": "1.0.47",
"permissions": ["storage"],
"permissions": [
"storage"
],
"icons": {
"16": "src/assets/icons/icon16.png",
"32": "src/assets/icons/icon32.png",
Expand All @@ -20,7 +22,10 @@
},
"content_scripts": [
{
"matches": ["*://store.steampowered.com/*", "*://steamcommunity.com/*"],
"matches": [
"*://store.steampowered.com/*",
"*://steamcommunity.com/*"
],
"exclude_matches": [
"*://store.steampowered.com/login/*",
"*://store.steampowered.com/join/*",
Expand All @@ -29,7 +34,6 @@
"*://steamcommunity.com/login/*",
"*://checkout.steampowered.com/*"
],

"js": [
"./src/utils/api.js",
"./src/data/currencies.js",
Expand All @@ -46,15 +50,22 @@
"./src/scripts/init.script.js",
"./src/scripts/changelog.script.js"
],
"css": ["./src/pages/styles/store.style.css"],
"css": [
"./src/pages/styles/store.style.css"
],
"run_at": "document_end",
"all_frames": true
}
],
"web_accessible_resources": [
{
"resources": ["src/assets/*"],
"matches": ["*://store.steampowered.com/*", "*://steamcommunity.com/*"]
"resources": [
"src/assets/*"
],
"matches": [
"*://store.steampowered.com/*",
"*://steamcommunity.com/*"
]
}
],
"commands": {
Expand All @@ -63,6 +74,7 @@
"description": "Toggle between currencies"
}
},
"host_permissions": ["https://store.steampowered.com/*"]
"host_permissions": [
"https://store.steampowered.com/*"
]
}

30 changes: 23 additions & 7 deletions manifest_firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"name": "Steam Currency Converter",
"description": "Seamlessly Convert Steam Prices to Local Currency!",
"version": "1.0.47",
"permissions": ["storage"],
"permissions": [
"storage"
],
"icons": {
"16": "src/assets/icons/icon16.png",
"32": "src/assets/icons/icon32.png",
Expand All @@ -15,7 +17,9 @@
"default_icon": "src/assets/icons/icon128.png"
},
"background": {
"scripts": ["./src/background.js"]
"scripts": [
"./src/background.js"
]
},
"browser_specific_settings": {
"gecko": {
Expand All @@ -24,7 +28,10 @@
},
"content_scripts": [
{
"matches": ["*://store.steampowered.com/*", "*://steamcommunity.com/*"],
"matches": [
"*://store.steampowered.com/*",
"*://steamcommunity.com/*"
],
"exclude_matches": [
"*://store.steampowered.com/login/*",
"*://store.steampowered.com/join/*",
Expand All @@ -49,16 +56,25 @@
"./src/scripts/init.script.js",
"./src/scripts/changelog.script.js"
],
"css": ["./src/pages/styles/store.style.css"],
"css": [
"./src/pages/styles/store.style.css"
],
"run_at": "document_end",
"all_frames": true
}
],
"web_accessible_resources": [
{
"resources": ["src/assets/*"],
"matches": ["*://store.steampowered.com/*", "*://steamcommunity.com/*"]
"resources": [
"src/assets/*"
],
"matches": [
"*://store.steampowered.com/*",
"*://steamcommunity.com/*"
]
}
],
"host_permissions": ["https://store.steampowered.com/*"]
"host_permissions": [
"https://store.steampowered.com/*"
]
}

0 comments on commit f3fd63f

Please sign in to comment.