From b52f93d7d6ed28a91918ddb26b1720ad28b3600a Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 12 Apr 2020 15:25:09 +0200 Subject: [PATCH] updated qrz --- .drone.yml | 27 +++++++++++++----------- .gitignore | 3 ++- Makefile | 1 - ci-build.sh | 60 +++++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 61 insertions(+), 30 deletions(-) diff --git a/.drone.yml b/.drone.yml index b85433f..ee6825b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,7 +7,7 @@ steps: - name: build image: golang commands: - - ./ci-build.sh + - ./ci-build.sh build environment: GOOS: linux GOARCH: amd64 @@ -18,9 +18,10 @@ steps: api_key: from_secret: gitea_token files: dist/*.tar.gz - checksum: - - sha256 - - sha512 + title: $DRONE_TAG + checksum: + - sha256 + - sha512 when: event: tag @@ -33,7 +34,7 @@ steps: - name: build image: golang commands: - - ./ci-build.sh + - ./ci-build.sh build environment: GOOS: linux GOARCH: arm64 @@ -44,9 +45,10 @@ steps: api_key: from_secret: gitea_token files: dist/*.tar.gz - checksum: - - sha256 - - sha512 + title: $DRONE_TAG + checksum: + - sha256 + - sha512 when: event: tag @@ -59,7 +61,7 @@ steps: - name: build image: golang commands: - - ./ci-build.sh + - ./ci-build.sh build environment: GOOS: netbsd GOARCH: amd64 @@ -70,8 +72,9 @@ steps: api_key: from_secret: gitea_token files: dist/*.tar.gz - checksum: - - sha256 - - sha512 + title: $DRONE_TAG + checksum: + - sha256 + - sha512 when: event: tag diff --git a/.gitignore b/.gitignore index 2587d1b..77d21a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/dist /qrz -*.ini \ No newline at end of file +*.ini diff --git a/Makefile b/Makefile index 99e0eba..3d5353f 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ GOCMD=go GOBUILDCMD=${GOCMD} build GOOPTIONS=-mod=vendor -ldflags="-s -w" -PACKRCMD=${GOPATH}/bin/packr2 RMCMD=rm BINNAME=qrz diff --git a/ci-build.sh b/ci-build.sh index 28506c8..2795770 100755 --- a/ci-build.sh +++ b/ci-build.sh @@ -1,20 +1,48 @@ #!/bin/bash -VERSION="" +RELEASEDIR=dist +RELEASENAME=qrz +VERSION="0" -if [[ ! -z $DRONE_TAG ]] -then - VERSION=$DRONE_TAG -else - VERSION=$DRONE_COMMIT -fi +GOOPTIONS="-mod=vendor -ldflags='-s -w'" +SRCFILES=cmd/qrz/*.go -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 +build() { + if [[ ! -z $DRONE_TAG ]] + then + VERSION=$DRONE_TAG + elif [[ ! -z $DRONE_TAG ]] + then + VERSION=$DRONE_COMMIT + fi + + if [[ ! -d $RELEASEDIR ]] + then + mkdir dist + fi + if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]] + then + RELEASENAME=qrz-${VERSION}-${GOOS}-${GOARCH} + fi + go build -o ${RELEASEDIR}/${RELEASENAME} ${GOOPTIONS} ${SRCFILES} + if [[ ! -z $DRONE_TAG ]] + then + cd ${RELEASEDIR} + tar -czvf ${RELEASENAME}.tar.gz ${RELEASENAME} + fi +} + +clean() { + rm -rf $RELEASEDIR +} + +case $1 in + "build") + build + ;; + "clean") + clean + ;; + *) + ;; +esac