forked from t2bot/matrix-media-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-dist.sh
36 lines (30 loc) · 1.04 KB
/
build-dist.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
#!/bin/bash
set -ex
rm -rfv $PWD/bin/*
mkdir $PWD/bin/dist
GOBIN=$PWD/bin go install -v ./cmd/utilities/compile_assets
$PWD/bin/compile_assets
arches=("amd64")
oses=("windows" "linux")
for os in "${oses[@]}"
do
for arch in "${arches[@]}"
do
pth="$os-$arch"
mkdir $PWD/bin/$pth
GOOS=$os GOARCH=$arch GOBIN=$PWD/bin go build -o $PWD/bin/$pth -a -ldflags "-X github.com/t2bot/matrix-media-repo/common/version.Version=$(git describe --tags)" -v ./cmd/...
GOOS=$os GOARCH=$arch GOBIN=$PWD/bin go build -pgo=pgo_media_repo.pprof -o $PWD/bin/$pth -a -ldflags "-X github.com/t2bot/matrix-media-repo/common/version.Version=$(git describe --tags)" -v ./cmd/workers/media_repo
cd $PWD/bin/$pth
if [ "$arch" == "amd64" ]; then
arch="x64"
fi
if [ "$os" == "windows" ]; then
for file in * ; do mv -v $file ../dist/${file%.*}-win-${arch}.exe; done;
else
for file in * ; do mv -v $file ../dist/${file}-${os}-${arch}; done;
fi
cd ../../
rm -rfv $PWD/bin/$pth
done
done
rm -rfv $PWD/bin/dist/compile_assets*