-
Notifications
You must be signed in to change notification settings - Fork 1
/
makedist
executable file
·43 lines (38 loc) · 1.28 KB
/
makedist
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
#!/bin/bash
# Go cross-compile
# Usually, only the VERSION changes.
# The OSLIST and ARCHLIST can change, as well.
# No need to change anything below ####
#
VERSION=$(<internal/cmd/version)
TOOLNAME=gen
OSLIST=(linux darwin windows)
ARCHLIST=(amd64 x86_64 386)
####
DISTDIR=dist/${VERSION}
mkdir -p ${DISTDIR}
echo "Compiling version ${VERSION}:"
for os in ${OSLIST[*]}; do
for arch in ${ARCHLIST[*]}; do
EXT=""
if [[ ${os} == "windows" ]]; then
EXT=".exe"
fi
GOOS=${os}
GOARCH=${arch}
echo "Compiling ${GOOS}/${GOARCH}..."
OUTPUTFILE=${DISTDIR}/${TOOLNAME}-${VERSION}-${GOOS}.${GOARCH}${EXT}
GOOS=${GOOS} GOARCH=${GOARCH} go build -trimpath -o ${OUTPUTFILE} *.go
file ${OUTPUTFILE}
done
done
# for distributions - homebrew & scoop
cd ${DISTDIR}
# for homebrew distribution, rename darwin.amd64, gz, shasum
cp ${TOOLNAME}-${VERSION}-darwin.amd64 ${TOOLNAME}
tar -czf ${TOOLNAME}-${VERSION}.tar.gz ${TOOLNAME}
shasum -a 256 ${TOOLNAME}-${VERSION}.tar.gz > ${TOOLNAME}-${VERSION}.tar.gz.shasum256
# for scoop distribution, rename windows.amd64.exe, zip, shasum
cp ${TOOLNAME}-${VERSION}-windows.amd64.exe ${TOOLNAME}.exe
zip ${TOOLNAME}-${VERSION}.64.exe.zip ${TOOLNAME}.exe
shasum -a 256 ${TOOLNAME}-${VERSION}.64.exe.zip > ${TOOLNAME}-${VERSION}.64.exe.zip.shasum256