#!/bin/bash

VERSION=""

if [[ ! -z $DRONE_TAG ]]
then
  VERSION=$DRONE_TAG
else
  VERSION=$DRONE_COMMIT
fi

if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]]
then
  mkdir dist
  go build -o dist/qrz-${VERSION}-${GOOS}-${GOARCH} -mod=vendor -ldflags='-s -w' cmd/qrz/*.go
  cd dist
  tar -czvf qrz-${VERSION}-${GOOS}-${GOARCH}.tar.gz qrz-${VERSION}-${GOOS}-${GOARCH}
else
  echo "Required variables not set"
fi
