-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·57 lines (44 loc) · 1010 Bytes
/
build.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
#!/bin/bash
source src/check_os.sh
function build() {
local out=$1
generate_bin "$out"
generate_checksum "$out"
echo "⚡️Build completed⚡️"
}
function generate_bin() {
local out=$1
local temp
temp="$(dirname "$out")/temp.sh"
echo '#!/bin/bash' > "$temp"
echo "Generating create-pr in the '$(dirname "$out")' folder..."
for file in src/*.sh; do
{
echo "# $file"
tail -n +2 "$file" >> "$temp"
echo ""
} >> "$temp"
done
cat create-pr >> "$temp"
grep -v '^source' "$temp" > "$out"
rm "$temp"
chmod u+x "$out"
}
function generate_checksum() {
local out=$1
if [[ "$_OS" == "Windows" ]]; then
return
fi
if [[ "$_OS" == "OSX" ]]; then
checksum=$(shasum -a 256 "$out")
elif [[ "$_OS" == "Linux" ]]; then
checksum=$(sha256sum "$out")
fi
echo "$checksum" > "$(dirname "$out")/checksum"
echo "$checksum"
}
########################
######### MAIN #########
########################
mkdir -p "bin"
build "bin/create-pr"