updated drone config
This commit is contained in:
parent
b5c41384e3
commit
cc2c7c0300
117
.drone.yml
117
.drone.yml
@ -1,3 +1,24 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: cleanup-before
|
||||
|
||||
steps:
|
||||
- name: clean
|
||||
image: alpine
|
||||
commands:
|
||||
- rm -rf /build/*
|
||||
volumes:
|
||||
- name: build
|
||||
path: /build
|
||||
when:
|
||||
event: tag
|
||||
|
||||
volumes:
|
||||
- name: build
|
||||
host:
|
||||
path: /tmp/weather/build
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
@ -11,18 +32,17 @@ steps:
|
||||
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: "*.tar.gz"
|
||||
checksum:
|
||||
- sha256
|
||||
- sha512
|
||||
when:
|
||||
event: tag
|
||||
volumes:
|
||||
- name: build
|
||||
path: /build
|
||||
|
||||
volumes:
|
||||
- name: build
|
||||
host:
|
||||
path: /tmp/weather/build
|
||||
|
||||
depends_on:
|
||||
- cleanup-before
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
@ -37,6 +57,33 @@ steps:
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: arm64
|
||||
volumes:
|
||||
- name: build
|
||||
path: /build
|
||||
|
||||
volumes:
|
||||
- name: build
|
||||
host:
|
||||
path: /tmp/weather/build
|
||||
|
||||
depends_on:
|
||||
- cleanup-before
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: gitea-release
|
||||
|
||||
steps:
|
||||
- name: move
|
||||
image: alpine
|
||||
commands:
|
||||
- mv build/* ./
|
||||
volumes:
|
||||
- name: build
|
||||
path: /drone/src/build
|
||||
when:
|
||||
event: tag
|
||||
- name: release
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
@ -47,5 +94,51 @@ steps:
|
||||
checksum:
|
||||
- sha256
|
||||
- sha512
|
||||
title: VERSION
|
||||
volumes:
|
||||
- name: build
|
||||
path: /drone/src/build
|
||||
when:
|
||||
event: tag
|
||||
- name: ls
|
||||
image: alpine
|
||||
commands:
|
||||
- find .
|
||||
volumes:
|
||||
- name: build
|
||||
path: /drone/src/build
|
||||
when:
|
||||
event: tag
|
||||
|
||||
volumes:
|
||||
- name: build
|
||||
host:
|
||||
path: /tmp/weather/build
|
||||
|
||||
depends_on:
|
||||
- default-linux-amd64
|
||||
- default-linux-arm64
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: cleanup-after
|
||||
|
||||
steps:
|
||||
- name: clean
|
||||
image: alpine
|
||||
commands:
|
||||
- rm -rf /build/*
|
||||
volumes:
|
||||
- name: build
|
||||
path: /build
|
||||
when:
|
||||
event: tag
|
||||
|
||||
volumes:
|
||||
- name: build
|
||||
host:
|
||||
path: /tmp/weather/build
|
||||
|
||||
depends_on:
|
||||
- gitea-release
|
||||
|
18
ci-build.sh
18
ci-build.sh
@ -8,24 +8,38 @@ GOOPTIONS="-mod=vendor"
|
||||
SRCFILES=cmd/weather/*.go
|
||||
|
||||
build() {
|
||||
echo "Begin of build"
|
||||
if [[ ! -z $DRONE_TAG ]]
|
||||
then
|
||||
echo "Drone tag set, let's do a release"
|
||||
VERSION=$DRONE_TAG
|
||||
echo "${PROJECTNAME} ${VERSION}" > /build/VERSION
|
||||
elif [[ ! -z $DRONE_TAG ]]
|
||||
then
|
||||
echo "Drone not set, let's only do a build"
|
||||
VERSION=$DRONE_COMMIT
|
||||
fi
|
||||
|
||||
if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]]
|
||||
then
|
||||
echo "Let's set a release name"
|
||||
RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH}
|
||||
fi
|
||||
|
||||
echo "Building project"
|
||||
go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES}
|
||||
|
||||
if [[ ! -z $DRONE_TAG ]]
|
||||
then
|
||||
tar -czvf ${RELEASENAME}.tar.gz ${PROJECTNAME}
|
||||
echo "Let's make archives"
|
||||
mkdir -p /build
|
||||
tar -czvf /build/${RELEASENAME}.tar.gz ${PROJECTNAME}
|
||||
fi
|
||||
|
||||
echo "Removing binary file"
|
||||
rm ${PROJECTNAME}
|
||||
|
||||
echo "End of build"
|
||||
}
|
||||
|
||||
clean() {
|
||||
@ -40,5 +54,7 @@ case $1 in
|
||||
clean
|
||||
;;
|
||||
*)
|
||||
echo "No options choosen"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -11,6 +11,8 @@ import (
|
||||
client "github.com/influxdata/influxdb1-client/v2"
|
||||
)
|
||||
|
||||
const url = "https://api.openweathermap.org/data/2.5/weather?q=%s&appid=%s&units=%s"
|
||||
|
||||
// FetchData fetch data from api
|
||||
func FetchData(c *config.Config, city string) (Data, error) {
|
||||
var d Data
|
||||
@ -22,7 +24,7 @@ func FetchData(c *config.Config, city string) (Data, error) {
|
||||
DisableCompression: false,
|
||||
}}
|
||||
|
||||
q := fmt.Sprintf("https://api.openweathermap.org/data/2.5/weather?q=%s&appid=%s&units=%s", city, c.WeatherAppID, c.WeatherUnits)
|
||||
q := fmt.Sprintf(url, city, c.WeatherAppID, c.WeatherUnits)
|
||||
|
||||
r, err := httpClient.Get(q)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user