-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_release.sh
87 lines (64 loc) · 1.72 KB
/
package_release.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
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
set -e
git_branch=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
oses=(
"linux"
"windows"
"darwin"
)
arches=(
"386"
"amd64"
"arm64"
)
artifactDir="./artifacts"
rm -rf "${artifactDir}"
mkdir -p "${artifactDir}"
generate_release_artifacts(){
local os=$1
local arch=$2
# set up dir
binDirName="icombo_${git_branch}_${os}_${arch}"
echo "building binary package for ${binDirName}"
binDirPath="${artifactDir}/${binDirName}"
mkdir -p "${binDirPath}"
# build binary
binName="icombo"
if [ "$os" == "windows" ]
then
binName="${binName}.exe"
fi
GOOS=$os GOARCH=$arch go build -o "${binDirPath}/${binName}"
# package binary
# create zip
zip -rjD "${artifactDir}/${binDirName}.zip" "${binDirPath}/"
# create tar
tarPath="${artifactDir}/${binDirName}.tar.gz"
tar -C "${binDirPath}" -czvf "${tarPath}" "${binName}"
echo ""
echo "building example package for ${binDirName}"
# add example file
cp -r "./example/"* "${binDirPath}"
# remove outputs so users can see it work
rm -rf "${binDirPath}/output_images"
# package example project
# create zip
(cd "${binDirPath}" && zip -r "../../artifacts/${binDirName}_example_project.zip" .)
# create tar
tarPath="${artifactDir}/${binDirName}_example_project.tar.gz"
tar -C "${binDirPath}" -czvf "${tarPath}" "."
rm -rf "${binDirPath}"
echo ""
}
for os in "${oses[@]}"
do
for arch in "${arches[@]}"
do
if [ "$os" == "darwin" ] && [ "$arch" == "386" ]
then
continue
fi
generate_release_artifacts $os $arch &
done
wait
done