Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Distribute windows artifact as coder.exe in a .zip #105

Merged
merged 1 commit into from
Aug 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions ci/steps/build.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#!/bin/bash

# Make pushd and popd silent
pushd () { builtin pushd "$@" > /dev/null ; }
popd () { builtin popd > /dev/null ; }
pushd() { builtin pushd "$@" >/dev/null; }
popd() { builtin popd >/dev/null; }

set -euo pipefail
cd "$(dirname "$0")"

export GOARCH=amd64
tag=$(git describe --tags)

build(){
build() {
tmpdir=$(mktemp -d)
go build -ldflags "-X main.version=${tag}" -o "$tmpdir/coder" ../../cmd/coder

pushd "$tmpdir"
tarname="coder-cli-$GOOS-$GOARCH.tar.gz"
tar -czf "$tarname" coder
if [[ "$GOOS" == "windows" ]]; then
artifact="coder-cli-$GOOS-$GOARCH.zip"
mv coder coder.exe
zip "$artifact" coder.exe
else
artifact="coder-cli-$GOOS-$GOARCH.tar.gz"
tar -czf "$artifact" coder
fi
popd

mkdir -p ../bin
cp "$tmpdir/$tarname" ../bin/$tarname
mkdir -p ../bin
cp "$tmpdir/$artifact" ../bin/$artifact
rm -rf "$tmpdir"
}

Expand Down