forked from mandiant/GoReSym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_test_files.sh
executable file
·35 lines (31 loc) · 2.06 KB
/
build_test_files.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
#!/bin/bash
trap "exit" INT
sudo rm -rf $(pwd)/test/build
versions=("1.21" "1.20" "1.19" "1.18" "1.17" "1.16" "1.15" "1.14" "1.13" "1.12" "1.11" "1.10" "1.9" "1.8" "1.7" "1.6" "1.5")
for v in "${versions[@]}"
do
GO_TAG=$v
GO_VER=$(echo "$GO_TAG" | tr -d '.')
mkdir -p $(pwd)/test/build/"$ver"/
rm -f Dockerfile.test
cat <<EOF >Dockerfile.test
FROM golang:$GO_TAG-alpine
ARG ver=$GO_VER
ENV ver \${ver}
WORKDIR \$ver/src/testproject
COPY ./testproject ./
RUN apk update && apk add --no-cache git
CMD mkdir -p /tmp/output/build/\$ver/ && export GOARCH=amd64 \
&& export GOOS=linux && go build ./ && mv testproject /tmp/output/build/\$ver/testproject_lin && go build -ldflags="-s -w" ./ && mv testproject /tmp/output/build/\$ver/testproject_lin_stripped \
&& export GOOS=windows && go build ./ && mv testproject.exe /tmp/output/build/\$ver/testproject_win.exe && go build -ldflags="-s -w" ./ && mv testproject.exe /tmp/output/build/\$ver/testproject_win_stripped.exe \
&& export GOOS=darwin && go build ./ && mv testproject /tmp/output/build/\$ver/testproject_mac && go build -ldflags="-s -w" ./ && mv testproject /tmp/output/build/\$ver/testproject_mac_stripped \
&& export GOARCH=386 \
&& export GOOS=linux && go build ./ && mv testproject /tmp/output/build/\$ver/testproject_lin_32 && go build -ldflags="-s -w" ./ && mv testproject /tmp/output/build/\$ver/testproject_lin_stripped_32 \
&& export GOOS=windows && go build ./ && mv testproject.exe /tmp/output/build/\$ver/testproject_win_32.exe && go build -ldflags="-s -w" ./ && mv testproject.exe /tmp/output/build/\$ver/testproject_win_stripped_32.exe \
&& export GOOS=darwin && go build ./ && mv testproject /tmp/output/build/\$ver/testproject_mac_32 && go build -ldflags="-s -w" ./ && mv testproject /tmp/output/build/\$ver/testproject_mac_stripped_32
EOF
docker build -f Dockerfile.test . -t goresym_testproject
docker run -v $(pwd)/test:/tmp/output/ goresym_testproject
done
rm Dockerfile.test
unzip $(pwd)/test/weirdbins.zip -d $(pwd)/test/