fix(travis): build multiple architectures
This commit is contained in:
parent
dbdd541ffb
commit
6835d4793b
7
.env
7
.env
@ -1,7 +0,0 @@
|
||||
PG_INTERN_PORT=5432
|
||||
PG_EXTERN_PORT=5432
|
||||
PG_NAME=public
|
||||
PG_USER=postgres
|
||||
PG_PASSWORD=postgres
|
||||
|
||||
TZ=Europe/Berlin
|
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,3 +1,13 @@
|
||||
flucky*
|
||||
# absolute files
|
||||
.env
|
||||
flucky
|
||||
flucky.rpm
|
||||
flucky.tar.bz2
|
||||
flucky.tar.gz
|
||||
flucky.tar.xz
|
||||
|
||||
# relative files
|
||||
**/bindata*.go
|
||||
.vscode
|
||||
|
||||
# directories
|
||||
.vscode/
|
||||
|
32
.travis.yml
32
.travis.yml
@ -1,24 +1,22 @@
|
||||
language: go
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: "build"
|
||||
name: go-build
|
||||
script: make container-go-build
|
||||
# - stage: "test"
|
||||
# name: go-test
|
||||
# script: make container-go-test
|
||||
- stage: "pre-deploy"
|
||||
name: rpm-build
|
||||
script: make container-rpm-build
|
||||
- stage: build
|
||||
name: go-build
|
||||
script: make container/all
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: NyeJvsDRo/gDl3KLaE4SMOezeUN9TXzZcRF8PfByf0PS9nx8Al0hjTzgC9BFvzS7GmJKfKcJMORzWsUKroX8wvN6MjboVZuFMZqgkb2R9aamzKWINB3zzm0A42UNM79benh0NKiYiN2CvxSON1duMTlGKv3adRUm5oAXyU0MwvwacGCNxI5xrJJu7RCucMyQrvS6g+TqGjzfke13Oft02Qwh0qFNYF5MRe6cxXeFba/2r17a34ZEySi5SfwcRzUfXaU3juYzsxfWGm3+4sHI7E05NHXupgN0hTaqSggAf/ZLE68lrSwgUCSM4/QJALk2DQoMzp2KBqaiIOHN4/llGiTE4NXVUz58Vrhj25OBWBARPafekqJuBYzo3YwMSv4GQgsMDVa5ni03TB82GQltWS2xodncfUsRheloL72UjA9MXRxk8lwv7POp+rIo9SOD/GOtYcuGTc25kHNzVHidp40rRXWB2y72lpL5FPSaSLw0eXP4pYysFNM/4sKS7E/zdEEs+JS/X8A+vJcs5vdeZV5rnjkEP3DjASowWmm6CVw5bGlx9dMM6a5HgLPMqG67dwqC0QL5BKv3DGqRMWzmybK46SStNmIocEk7mKMU+Ga4uOLVHpqpaU7BpFgTIbZfRJcGhdQJSw/yXqqPK0HrY4E3t1nEIrpr8sU4AZUaQ+8=
|
||||
file: flucky.rpm
|
||||
on:
|
||||
repo: volker-raschek/flucky
|
||||
tags: true
|
||||
skip_cleanup: true
|
||||
- provider: script
|
||||
script: make container/release
|
||||
# skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
on_failure: change
|
130
Makefile
130
Makefile
@ -16,41 +16,113 @@ CONTAINER_RUNTIME?=$(shell which docker)
|
||||
# BUILD_IMAGE
|
||||
BUILD_IMAGE:=volkerraschek/build-image:latest
|
||||
|
||||
# GO ENVIRONMENT
|
||||
GOARCH?=amd64
|
||||
GOOS?=linux
|
||||
# GH_USER/GITHUB_TOKEN
|
||||
# It's the user name from github.com and his token. This token and the username
|
||||
# can be set over encrypted environment variables in the ci/cd pipeline
|
||||
GITHUB_USER=volker-raschek
|
||||
GITHUB_TOKEN?=""
|
||||
|
||||
# default build
|
||||
go-build: bindata
|
||||
GOOS=${GOOS} \
|
||||
GOARCH=${GOARCH} \
|
||||
go build -ldflags "-X main.version=${VERSION}"
|
||||
chown ${UID}:${GID} ./*
|
||||
# EXECUTABLE
|
||||
# Executable binary which should be compiled for different architecures
|
||||
EXECUTABLE:=flucky
|
||||
|
||||
go-test: go-build
|
||||
go test -v ./pkg/...
|
||||
# UNIX_EXECUTABLES
|
||||
# Define all executables for different architectures and operation systems
|
||||
UNIX_EXECUTABLES := \
|
||||
darwin/amd64/$(EXECUTABLE) \
|
||||
freebsd/amd64/$(EXECUTABLE) \
|
||||
linux/amd64/$(EXECUTABLE) \
|
||||
linux/arm/5/$(EXECUTABLE) \
|
||||
linux/arm/7/$(EXECUTABLE) \
|
||||
|
||||
rpm-build: go-build
|
||||
rpm-builder \
|
||||
--arch x86_64 \
|
||||
--compression gzip \
|
||||
--exec-file "flucky:/usr/bin/flucky" \
|
||||
--file "systemd/flucky.service:/usr/lib/systemd/system/flucky.service" \
|
||||
--version ${VERSION} \
|
||||
flucky
|
||||
# EXECUTABLE_TARGETS
|
||||
# Include the relative paths to all executables
|
||||
EXECUTABLE_TARGETS=$(UNIX_EXECUTABLES:%=bin/%)
|
||||
|
||||
# COMPRSSED_EXECUTABLES
|
||||
# Append to all defined executables the compression extentions to detect the
|
||||
# different make steps which compress the binary
|
||||
COMPRESSED_EXECUTABLES=$(UNIX_EXECUTABLES:%=%.tar.bz2) $(UNIX_EXECUTABLES:%=%.tar.gz) $(UNIX_EXECUTABLES:%=%.tar.xz)
|
||||
COMPRESSED_EXECUTABLE_TARGETS=$(COMPRESSED_EXECUTABLES:%=bin/%)
|
||||
|
||||
# PHONY
|
||||
# To avoid a conflict with an existing file and a defined make step
|
||||
.PHONY: clean container/${EXECUTABLE_TARGETS} container/test release remote test
|
||||
|
||||
all: ${EXECUTABLE}
|
||||
|
||||
$(EXECUTABLE): bindata
|
||||
go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
bin/tmp/${EXECUTABLE}: bindata
|
||||
go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
# arm
|
||||
bin/linux/arm/5/${EXECUTABLE}: bindata
|
||||
GOARM=5 GOARCH=arm go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
bin/linux/arm/7/${EXECUTABLE}: bindata
|
||||
GOARM=7 GOARCH=arm go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
# 386
|
||||
bin/darwin/386/$(EXECUTABLE): bindata
|
||||
GOARCH=386 GOOS=darwin go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
bin/linux/386/$(EXECUTABLE): bindata
|
||||
GOARCH=386 GOOS=linux go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
# amd64
|
||||
bin/freebsd/amd64/$(EXECUTABLE): bindata
|
||||
GOARCH=amd64 GOOS=freebsd go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
bin/darwin/amd64/$(EXECUTABLE): bindata
|
||||
GOARCH=amd64 GOOS=darwin go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
bin/linux/amd64/$(EXECUTABLE): bindata
|
||||
GOARCH=amd64 GOOS=linux go build -ldflags "-X main.version=${VERSION}" -o "$@"
|
||||
|
||||
bindata:
|
||||
go-bindata -pkg db -o ./pkg/db/bindataSQL.go ./pkg/db/sql/***
|
||||
go-bindata -pkg goldenfiles -o ./test/goldenfiles/bindata.go ./test/goldenfiles/json/***
|
||||
|
||||
container-go-build:
|
||||
$(MAKE) container-run COMMAND=go-build
|
||||
%.tar.bz2: %
|
||||
tar --create --bzip2 --file "$@" "$<"
|
||||
|
||||
container-go-test:
|
||||
$(MAKE) container-run COMMAND=go-test
|
||||
%.tar.gz: %
|
||||
tar --create --gunzip --file "$@" "$<"
|
||||
|
||||
container-rpm-build:
|
||||
$(MAKE) container-run COMMAND=rpm-build
|
||||
%.tar.xz: %
|
||||
tar --create --xz --file "$@" "$<"
|
||||
|
||||
|
||||
test: ${EXECUTABLE}
|
||||
go test -v ./pkg/...
|
||||
|
||||
|
||||
release: clean
|
||||
$(MAKE) $(COMPRESSED_EXECUTABLE_TARGETS)
|
||||
github-release release \
|
||||
--user ${GITHUB_USER} \
|
||||
--repo ${EXECUTABLE} \
|
||||
--tag ${VERSION}
|
||||
|
||||
$(foreach FILE,$(COMPRESSED_EXECUTABLES),github-release upload --user ${GITHUB_USER} --repo ${EXECUTABLE} --tag ${VERSION} --name $(subst /,-,$(FILE)) --file bin/$(FILE) --replace;)
|
||||
|
||||
|
||||
clean:
|
||||
rm ${EXECUTABLE} || true
|
||||
rm --recursive --force bin/ || true
|
||||
|
||||
|
||||
container/all:
|
||||
$(MAKE) container-run COMMAND=all
|
||||
|
||||
|
||||
container/test:
|
||||
$(MAKE) container-run COMMAND=test
|
||||
|
||||
container/release:
|
||||
$(MAKE) container-run COMMAND=release
|
||||
|
||||
container-run:
|
||||
${CONTAINER_RUNTIME} run \
|
||||
@ -61,10 +133,8 @@ container-run:
|
||||
UID=${UID} \
|
||||
GID=${GID} \
|
||||
VERSION=${VERSION} \
|
||||
GOOS=${GOOS} \
|
||||
GOARCH=${GOARCH}
|
||||
GITHUB_TOKEN=${GITHUB_TOKEN}
|
||||
|
||||
remote:
|
||||
$(MAKE) go-build GOARCH=arm
|
||||
scp flucky ${FLUCKY_REMOTE}:/usr/local/bin
|
||||
remote: bin/linux/arm/7/${EXECUTABLE}
|
||||
scp bin/linux/arm/7/${EXECUTABLE} ${FLUCKY_REMOTE}:/usr/local/bin
|
||||
ssh ${FLUCKY_REMOTE} "chmod +x /usr/local/bin/flucky"
|
||||
|
9
systemd/flucky.service
Normal file
9
systemd/flucky.service
Normal file
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Start flucky daemon
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/flucky daemon
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user