-
Notifications
You must be signed in to change notification settings - Fork 2
/
zip.sh
executable file
·76 lines (65 loc) · 1.91 KB
/
zip.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Re-create a build of extension by webpack to dist directory
if [ -d "dist" ]; then
rm -r "dist"
echo "'dist' removed"
else
echo "'dist' no found"
fi
npm run build
##########################################################
# Create a .zip file of Google Chrome extension package #
##########################################################
current_date_time=$(date +'%d-%m-%Y_%H:%M:%S')
version=$(jq '.version' dist/manifest.json | tr -d '"')
zip_filename="band-play-build_${current_date_time}_${version}.zip"
temp_dir="band-play-build"
# Files that will be included to .zip
include_files=(
"dist/assets/bandcamp.png"
"dist/assets/buymeacoffee.png"
"dist/assets/close.png"
"dist/assets/github.png"
"dist/assets/guide.png"
"dist/assets/keys/key-0.png"
"dist/assets/keys/key-9.png"
"dist/assets/keys/key-B.png"
"dist/assets/keys/key-down.png"
"dist/assets/keys/key-L.png"
"dist/assets/keys/key-left.png"
"dist/assets/keys/key-N.png"
"dist/assets/keys/key-O.png"
"dist/assets/keys/key-P.png"
"dist/assets/keys/key-right.png"
"dist/assets/keys/key-up.png"
"dist/assets/logo-16.png"
"dist/assets/logo-32.png"
"dist/assets/logo-48.png"
"dist/assets/logo-128.png"
"dist/assets/rate.png"
"dist/background.js"
"dist/content.js"
"dist/manifest.json"
"dist/options.html"
"dist/options.js"
"dist/vendor.js"
)
# Create a temporary directory
mkdir "$temp_dir"
# Copy to the temporary directory
for file in "${include_files[@]}"; do
# Remove the 'dist/' prefix from the file path
file_without_dist="${file#dist/}"
# Create the destination directory
destination_dir="$temp_dir/$(dirname "$file_without_dist")"
if [ ! -d "$destination_dir" ]; then
mkdir -p "$destination_dir"
fi
# Copy the file to the temporary directory
cp "$file" "$destination_dir/"
done
# Create a .zip file
zip -r "$zip_filename" "$temp_dir"
# Clean up the temporary directory
rm -r "$temp_dir"
echo "'$zip_filename' was created."