diff --git a/.drone.yml b/.drone.yml index ddcdeaa..a180403 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,34 +2,11 @@ kind: pipeline name: default steps: - name: create dist - image: alpine:latest + image: golang:latest-alpine commands: - - mkdir dist - - cp settings.yml.dist dist/settings.yml - when: - event: tag - -- name: Go Windows - image: golang:latest - commands: - - GOOS=windows go build -o dist/twitch-data-collector.exe *.go - - cd dist && zip twitch-data-collector-win-${DRONE_TAG}.zip twitch-data-collector.exe settings.yml && rm twitch-data-collector.exe - when: - event: tag - -- name: Go Linux AMD64 - image: golang:latest - commands: - - GOOS=linux GOARCH=amd64 go build -o dist/twitch-data-collector *.go - - cd dist && zip twitch-data-collector-linux-amd64-${DRONE_TAG}.zip twitch-data-collector settings.yml && twitch-data-collector - when: - event: tag - -- name: Go Linux ARM - image: golang:latest - commands: - - GOOS=linux GOARCH=arm go build -o dist/twitch-data-collector *.go - - cd dist && zip twitch-data-collector-linux-arm-${DRONE_TAG}.zip twitch-data-collector settings.yml && twitch-data-collector + - apk update + - apk add zip + - ./create_dist.sh when: event: tag diff --git a/create_dist.sh b/create_dist.sh new file mode 100755 index 0000000..ca792e1 --- /dev/null +++ b/create_dist.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +export basename=twitch-data-collector + +mkdir dist +cp settings.yml.dist dist/settings.yml + +go_build () { + go build -o dist/$basename-$DRONE_TAG-$GOOS-$GOARCH$ext *.go +} + +create_zip () { + cd dist + zip $basename-$DRONE_TAG-$GOOS-$GOARCH.zip $basename-$DRONE_TAG-$GOOS-$GOARCH$ext settings.yml + rm $basename-$DRONE_TAG-$GOOS-$GOARCH$ext + cd .. +} + +export GOARCH=amd64 +export GOOS=windows +export ext=".exe" +go_build +create_zip + +export ext="" +export GOOS=linux +go_build +create_zip + +rm dist/settings.yml