mirror of
https://github.com/KevinMidboe/traefik-etcd-advertiser.git
synced 2025-10-29 18:00:19 +00:00
drone ci config, releases go binary on github
This commit is contained in:
38
.drone.yml
Normal file
38
.drone.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: Build and publish
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: linux
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Build
|
||||||
|
image: golang
|
||||||
|
commands:
|
||||||
|
- make build
|
||||||
|
|
||||||
|
- name: Create release files
|
||||||
|
image: golang
|
||||||
|
commands:
|
||||||
|
- make release
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
|
||||||
|
- name: Upload release files
|
||||||
|
image: plugins/github-release
|
||||||
|
settings:
|
||||||
|
api_key:
|
||||||
|
from_secret: GHCR_UPLOAD_TOKEN
|
||||||
|
files: release/*
|
||||||
|
checksum:
|
||||||
|
- sha512
|
||||||
|
draft: true
|
||||||
|
when:
|
||||||
|
event: tag
|
||||||
|
---
|
||||||
|
kind: signature
|
||||||
|
hmac: e35934cf1ba5c663aec6e5cd3204912446cc3b98c7a05d85fbf20d0429577df2
|
||||||
|
|
||||||
|
...
|
||||||
53
Makefile
53
Makefile
@@ -2,19 +2,62 @@
|
|||||||
|
|
||||||
PROJECT_NAME=$(shell basename $(CURDIR))
|
PROJECT_NAME=$(shell basename $(CURDIR))
|
||||||
|
|
||||||
|
APPLICATION_NAME := traefik-etcd-advertiser
|
||||||
|
VERSION := $(shell git describe --tags HEAD 2>/dev/null || echo $(DRONE_TAG))
|
||||||
|
# PLATFORMS := darwin/amd64 darwin/arm64 linux/amd64 linux/arm linux/arm64 windows/amd64
|
||||||
|
PLATFORMS := darwin/arm64 linux/amd64
|
||||||
|
|
||||||
## build: build the application
|
## build: build the application
|
||||||
build:
|
build: install
|
||||||
export GO111MODULE="auto"; \
|
export GO111MODULE="auto"; \
|
||||||
go mod download; \
|
go mod download; \
|
||||||
go mod vendor; \
|
go mod vendor; \
|
||||||
CGO_ENABLED=0 go build -a -ldflags '-s' -installsuffix cgo -o main main.go
|
CGO_ENABLED=0 go build -a -ldflags '-s' -installsuffix cgo -o main main.go
|
||||||
|
|
||||||
|
|
||||||
|
release: install-vendor
|
||||||
|
@for platform in $(PLATFORMS); do \
|
||||||
|
GOOS=$$(echo $$platform | cut -d'/' -f1); \
|
||||||
|
GOARCH=$$(echo $$platform | cut -d'/' -f2); \
|
||||||
|
os=$$GOOS; \
|
||||||
|
if [ "$$os" = "darwin" ]; then \
|
||||||
|
os="macOS"; \
|
||||||
|
fi; \
|
||||||
|
output_name="$(APPLICATION_NAME)-$(VERSION)-$$os-$$GOARCH"; \
|
||||||
|
if [ "$$os" = "windows" ]; then \
|
||||||
|
output_name+=".exe"; \
|
||||||
|
fi; \
|
||||||
|
echo "Building release/$$output_name..."; \
|
||||||
|
env GO11MODULE="auto" CGO_ENABLED=0 \
|
||||||
|
GOOS=$$GOOS GOARCH=$$GOARCH go build \
|
||||||
|
-ldflags "-w -s -X main.Version=$(VERSION)" \
|
||||||
|
-o release/$$output_name; \
|
||||||
|
if [ $$? -ne 0 ]; then \
|
||||||
|
echo 'An error has occurred! Aborting.'; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
cd release > /dev/null; \
|
||||||
|
if [ "$$os" = "windows" ]; then \
|
||||||
|
zip "$$output_name.zip" "$$output_name"; \
|
||||||
|
rm "$$output_name"; \
|
||||||
|
else \
|
||||||
|
chmod a+x "$$output_name"; \
|
||||||
|
tar -czf "$$output_name.tar" "$$output_name"; \
|
||||||
|
rm "$$output_name"; \
|
||||||
|
fi; \
|
||||||
|
cd ..; \
|
||||||
|
done
|
||||||
|
|
||||||
## install: fetches go modules
|
## install: fetches go modules
|
||||||
install:
|
install:
|
||||||
export GO111MODULE="on"; \
|
export go111module="on"; \
|
||||||
go mod tidy; \
|
go mod tidy; \
|
||||||
go mod download \
|
go mod download \
|
||||||
|
|
||||||
|
install-vendor: install
|
||||||
|
export go111module="on"; \
|
||||||
|
go mod vendor
|
||||||
|
|
||||||
## server: runs the server with -race
|
## server: runs the server with -race
|
||||||
server:
|
server:
|
||||||
export GO111MODULE="on"; \
|
export GO111MODULE="on"; \
|
||||||
|
|||||||
Reference in New Issue
Block a user