forked from dbeck121/CPI-Helper-Chrome-Extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzipFiles.sh
executable file
·39 lines (31 loc) · 1.08 KB
/
zipFiles.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
MANIFEST_V3="manifest.json_v3"
if [ -f "$MANIFEST_V3" ]; then
echo "Please make sure we release only manifest v3. Current version is probably not v3."
exit 1
fi
echo "Copy readme to docs..."
cp README.md docs/readme/README.md
# copy paste readme root->docs
echo "Remove old zip file..."
rm -f ./bin/*.zip
# create a dynamic name + zip files as per manifest.json name and version field
name=""
version=""
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ "$line" == *"\"name\":"* ]]; then
name=$(echo "$line" | awk -F'"' '{print $4}')
elif [[ "$line" == *"\"version\":"* ]]; then
version=$(echo "$line" | awk -F'"' '{print $4}' | tr -d ',')
fi
done < manifest.json
# replace comma , space with underscore.
name="${name//,/}"
name="${name// /_}"
exclusions=("./docs/*" "./node_modules" "./images/v[1-3]/*" "./.*")
exclude_args=()
for pattern in "${exclusions[@]}"; do
exclude_args+=( -o -path "$pattern" )
done
exclude_args=( "${exclude_args[@]:1}" )
find . -type f ! \( "${exclude_args[@]}" \) -exec zip -r "bin/${name}_${version}.zip" {} +