added scripts for ci

This commit is contained in:
Paul 2020-04-12 15:27:10 +02:00
parent 0d14dc1d23
commit 973eba0d8b
2 changed files with 129 additions and 0 deletions

80
.drone.yml Normal file
View File

@ -0,0 +1,80 @@
---
kind: pipeline
type: docker
name: default-linux-amd64
steps:
- name: build
image: golang
commands:
- ./ci-build.sh build
environment:
GOOS: linux
GOARCH: amd64
- name: release
image: plugins/gitea-release
settings:
base_url: https://git.paulbsd.com
api_key:
from_secret: gitea_token
files: dist/*.tar.gz
title: $DRONE_TAG
checksum:
- sha256
- sha512
when:
event: tag
---
kind: pipeline
type: docker
name: default-linux-arm64
steps:
- name: build
image: golang
commands:
- ./ci-build.sh build
environment:
GOOS: linux
GOARCH: arm64
- name: release
image: plugins/gitea-release
settings:
base_url: https://git.paulbsd.com
api_key:
from_secret: gitea_token
files: dist/*.tar.gz
title: $DRONE_TAG
checksum:
- sha256
- sha512
when:
event: tag
---
kind: pipeline
type: docker
name: default-netbsd-amd64
steps:
- name: build
image: golang
commands:
- ./ci-build.sh build
environment:
GOOS: netbsd
GOARCH: amd64
- name: release
image: plugins/gitea-release
settings:
base_url: https://git.paulbsd.com
api_key:
from_secret: gitea_token
files: dist/*.tar.gz
title: $DRONE_TAG
checksum:
- sha256
- sha512
when:
event: tag

49
ci-build.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
PROJECTNAME=coronafana
RELEASEDIR=dist
RELEASENAME=${PROJECTNAME}
VERSION="0"
GOOPTIONS="-mod=vendor -ldflags='-s -w'"
SRCFILES=cmd/coronafana/*.go
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=${PROJECTNAME}-${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