diff --git a/.drone.sh b/.drone.sh index e0dde9d..ba54e81 100644 --- a/.drone.sh +++ b/.drone.sh @@ -5,10 +5,46 @@ # disable CGO for cross-compiling export CGO_ENABLED=0 -export now=$(TZ=Australia/Sydney date '+%Y%m%d-%H%M%S') -echo $now -echo "build commences" -go build -ldflags "-X main.sha1ver=`git rev-parse HEAD` -X main.buildTime=$now" -o api-tester . -echo "build complete" -sha256sum api-tester > api-tester_checksum.txt -ls -lah \ No newline at end of file +#branch=$(git rev-parse --abbrev-ref HEAD) +commit=$(git rev-parse HEAD) +#tag=$(git describe --tags --abbrev=0) +buildtime=$(TZ=Australia/Sydney date +%Y-%m-%dT%T%z) +#git_version=$(git describe --tags --always --long --dirty) +package_name=api-tester + +#echo "Current directory:" +#pwd + +platforms=("windows/amd64" "linux/amd64" "darwin/amd64") + +echo Building $package_name with git version: $git_version +for platform in "${platforms[@]}" +do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + output_name=$package_name'-'$GOOS'-'$GOARCH + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + + echo "build commences" + env GOOS=$GOOS GOARCH=$GOARCH go build -trimpath -ldflags="-X main.sha1ver=$commit -X main.buildTime=$buildtime" -o build/$output_name $package + if [ $? -ne 0 ]; then + echo 'An error has occurred! Aborting the script execution...' + exit 1 + fi + echo "build complete : $output_name" + sha256sum build/$output_name > build/${output_name}_checksum.txt + #ls -lah ./build/ +done + +ls -lah build + +#export now=$(TZ=Australia/Sydney date '+%Y%m%d-%H%M%S') +#echo $now +#echo "build commences" +#go build -ldflags "-X main.sha1ver=`git rev-parse HEAD` -X main.buildTime=$now" -o api-tester . +#echo "build complete" +#sha256sum api-tester > api-tester_checksum.txt +#ls -lah \ No newline at end of file diff --git a/.drone.yml b/.drone.yml index 7ab1cf1..40b9c3a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,6 +21,6 @@ steps: api_key: from_secret: GITEA_TOKEN base_url: https://git.coadcorp.com - files: api-tester + files: build/* checksum: sha256 prerelease: true