Skip to content

Commit

Permalink
Build script does not need gox anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSuisse committed Sep 11, 2018
1 parent 634ee6a commit 68b75ee
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,36 @@ SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
cd -P "$( dirname "$SOURCE" )/.."

OSARCH="linux/386 linux/amd64 linux/arm linux/arm64 darwin/386 darwin/amd64 windows/386 windows/amd64 freebsd/386 freebsd/amd64 freebsd/arm openbsd/386 openbsd/amd64 openbsd/arm netbsd/386 netbsd/amd64 netbsd/arm solaris/amd64"
SUPPORTED_ARCHES=( "linux/386" "linux/amd64" "linux/arm" "linux/arm64"
"darwin/386" "darwin/amd64"
"windows/386" "windows/amd64"
"freebsd/386" "freebsd/amd64" "freebsd/arm"
"openbsd/386" "openbsd/amd64" "openbsd/arm"
"netbsd/386" "netbsd/amd64" "netbsd/arm"
"solaris/amd64"
)

gox -osarch="$OSARCH" \
-ldflags="-X github.com/LeSuisse/vault-gpg-plugin/version.GitCommit='$(git rev-parse HEAD)'" \
-output="pkg/{{.OS}}_{{.Arch}}/vault-gpg-plugin" \
.
for supported_arch in "${SUPPORTED_ARCHES[@]}"
do
IFS="/" read -r -a os_arch_split <<< "$supported_arch"
os="${os_arch_split[0]}"
arch="${os_arch_split[1]}"
binary_extension=""
if [ "$os" == "windows" ]; then
binary_extension=".exe"
fi
echo "Building ${supported_arch}"
GOOS="$os" GOARCH="$arch" go build \
-ldflags="-X github.com/LeSuisse/vault-gpg-plugin/version.GitCommit='$(git rev-parse HEAD)'" \
-o "pkg/${os}_${arch}/vault-gpg-plugin${binary_extension}"
done

while IFS= read -r -d '' platform
do
osarch=$(basename "$platform")

pushd "$platform" >/dev/null 2>&1
sha256sum * > "$osarch".sha256sum
sha256sum -- * > "$osarch".sha256sum
zip ../"$osarch".zip ./*
popd >/dev/null 2>&1
done < <(find ./pkg -mindepth 1 -maxdepth 1 -type d -print0)

0 comments on commit 68b75ee

Please sign in to comment.