Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release with goreleaser #423

Merged
merged 6 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@ main
/dkron-executor-*
*.log
config/
*.deb
*.rpm
build/
builder/skel/
!builder/skel/.keep
dist
107 changes: 107 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
builds:
- main: ./builtin/bins/dkron-executor-http/
binary: dkron-executor-http
goos:
- freebsd
- windows
- darwin
- linux
goarch:
- amd64
- arm64

- main: ./builtin/bins/dkron-executor-shell/
binary: dkron-executor-shell
goos:
- freebsd
- windows
- darwin
- linux
goarch:
- amd64
- arm64

- main: ./builtin/bins/dkron-processor-files/
binary: dkron-processor-files
goos:
- freebsd
- windows
- darwin
- linux
goarch:
- amd64
- arm64

- main: ./builtin/bins/dkron-processor-log/
binary: dkron-processor-log
goos:
- freebsd
- windows
- darwin
- linux
goarch:
- amd64
- arm64

- main: ./builtin/bins/dkron-processor-syslog/
binary: dkron-processor-syslog
goos:
- freebsd
- windows
- darwin
- linux
goarch:
- amd64
- arm64

- main: .
binary: dkron
goos:
- freebsd
- windows
- darwin
- linux
goarch:
- amd64
- arm64
ldflags:
- -s -w -X github.com/victorcoder/dkron/dkron.Version={{.Version}}

nfpm:
vendor: Distributed Works
homepage: https://dkron.io
maintainer: Victor Castell <victor@distrib.works>
description: Distributed, fault tolerant job scheduling system
license: LGPL 3.0

formats:
- deb
- rpm

# Override default /usr/local/bin destination for binaries
bindir: /usr/bin

empty_folders:
- /var/log/dkron

#files:
# "builder/files/": "/etc/init.d"
# "path/**/glob": "/var/foo/glob"
config_files:
"builder/files/*.yml": "/etc/dkron/dkron.yml"

overrides:
rpm:
replacements:
amd64: x86_64

snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
139 changes: 2 additions & 137 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,144 +1,9 @@
BIN_NAME := dkron
DEP_VERSION=0.4.1
VERSION := 0.10.4
PKGNAME := dkron
LICENSE := LGPL 3.0
VENDOR := Distributed Works
URL := https://dkron.io
RELEASE := 0
OS := $(shell uname | tr '[:upper:]' '[:lower:]')
ARCH := amd64
PLUGINS=$(wildcard builtin/bins/dkron-*)
BINS=$(wildcard build/*/dkron-*)
DESC := Distributed, fault tolerant job scheduling system
MAINTAINER := Victor Castell <victor@distrib.works>
DOCKER_WDIR := /tmp/fpm
DOCKER_FPM := devopsfaith/fpm
SHA256SUMS := ${PKGNAME}_${VERSION}_SHA256SUMS

PLATFORMS := darwin_amd64 linux_amd64 linux_arm64 windows_amd64
TEMP = $(subst _, ,$@)
GOOS = $(word 1, $(TEMP))
GOARCH = $(word 2, $(TEMP))
TARS := $(foreach t,$(PLATFORMS),builder/skel/$(t))

LDFLAGS=-ldflags="-X github.com/victorcoder/dkron/dkron.Version=${VERSION}"

FPM_OPTS=-s dir -v $(VERSION) -n $(PKGNAME) \
--license "$(LICENSE)" \
--vendor "$(VENDOR)" \
--maintainer "$(MAINTAINER)" \
--architecture $(ARCH) \
--url "$(URL)" \
--description "$(DESC)" \
--config-files etc/ \
--verbose

DEB_OPTS=
RPM_OPTS= #--rpm-sign

default: build

.PHONY: build
build:
$(foreach p,$(PLUGINS),$(shell go build -o $(shell basename $(p)) ./$(p)))
go build ${LDFLAGS} -o main .

build_all: $(PLATFORMS)
$(PLATFORMS):
$(eval ext := $(if $(filter $(GOOS),windows),.exe))
$(foreach p,$(PLUGINS),$(shell GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o build/$(GOOS)_$(GOARCH)/$(shell basename $(p))$(ext) ./$(p)))
GOOS=$(GOOS) GOARCH=$(GOARCH) go build ${LDFLAGS} -o build/$(GOOS)_$(GOARCH)/${BIN_NAME}$(ext) .

builder/skel/%/etc/dkron/dkron.yml: builder/files/dkron.yml
mkdir -p "$(dir $@)"
cp $< "$@"

builder/skel/%/lib/systemd/system/dkron.service: builder/files/dkron.service
mkdir -p "$(dir $@)"
cp builder/files/dkron.service "$@"

builder/skel/%/usr/bin: build_all
mkdir -p $@
cp build/linux_amd64/* $@

builder/skel/%: build_all
mkdir -p $@
cp README.md LICENSE builder/files/dkron.yml $(wildcard build/$*)/* $@

.PHONY: tgz
tgz: $(addprefix builder/skel/,${PLATFORMS})
$(foreach p,$(PLATFORMS),$(shell tar zcvf dkron_${VERSION}_${p}.tar.gz -C builder/skel/${p} .))
$(foreach p,$(PLATFORMS),$(shell shasum -a 256 dkron_${VERSION}_${p}.tar.gz >> ${SHA256SUMS}))

.PHONY: deb
deb: builder/skel/deb/usr/bin
deb: builder/skel/deb/etc/dkron/dkron.yml
docker run --rm -it -v "${PWD}:${DOCKER_WDIR}" -w ${DOCKER_WDIR} ${DOCKER_FPM}:deb -t deb ${DEB_OPTS} \
--iteration ${RELEASE} \
--deb-systemd builder/files/dkron.service \
--chdir builder/skel/$@ \
${FPM_OPTS}
shasum -a 256 ${PKGNAME}_${VERSION}-${RELEASE}_amd64.deb >> ${SHA256SUMS}
# docker build --build-arg debfile=${PKGNAME}_${VERSION}-${RELEASE}_amd64.deb -f tests/deb/Dockerfile -t test_${PKGNAME}_${VERSION}_deb .

.PHONY: rpm
rpm: builder/skel/rpm/usr/bin
rpm: builder/skel/rpm/usr/lib/systemd/system/dkron.service
rpm: builder/skel/rpm/etc/dkron/dkron.yml
docker run --rm -it -v "${PWD}/rpmmacros:/root/.rpmmacros" \
-v "${PWD}:${DOCKER_WDIR}" -w ${DOCKER_WDIR} ${DOCKER_FPM}:rpm -t rpm ${RPM_OPTS} \
--iteration ${RELEASE} \
-C builder/skel/$@ \
${FPM_OPTS}
shasum -a 256 ${PKGNAME}-${VERSION}-${RELEASE}.x86_64.rpm >> ${PKGNAME}_${VERSION}_SHA256SUMS
# docker build --build-arg rpmfile=${PKGNAME}-${VERSION}-${RELEASE}.x86_64.rpm -f tests/rpm/Dockerfile -t test_${PKGNAME}_${VERSION}_rpm .

LINUX_PKGS := $(wildcard *.deb) $(wildcard *.rpm)
PKGS := $(wildcard *.tar.gz)

.PHONY: ghrelease
ghrelease:
github-release release \
--user victorcoder \
--repo dkron \
--tag v${VERSION} \
--name "${VERSION}" \
--description "See: https://github.com/victorcoder/dkron/blob/master/CHANGELOG.md" \

.PHONY: github-checksum
github-checksum: ghrelease
github-release upload \
--user victorcoder \
--repo dkron \
--name ${SHA256SUMS} \
--tag v${VERSION} \
--file ${SHA256SUMS}

.PHONY: github $(PKGS)
github: $(PKGS)
$(PKGS): github-checksum
github-release upload \
--user victorcoder \
--repo dkron \
--name $@ \
--tag v${VERSION} \
--file $@

LINUX_PKGS := $(wildcard dist/*.deb) $(wildcard dist/*.rpm)
.PHONY: fury $(LINUX_PKGS)
fury: $(LINUX_PKGS)
$(LINUX_PKGS): github
github-release upload \
--user victorcoder \
--repo dkron \
--name $@ \
--tag v${VERSION} \
--file $@
$(LINUX_PKGS):
fury push $@

.PHONY: release
release: clean deb rpm tgz fury

.PHONY: clean
clean:
rm -f main
Expand Down
Empty file removed builder/skel/.keep
Empty file.
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var versionCmd = &cobra.Command{
Short: "Show version",
Long: `Show the version`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Dkron v%s (Codename: %s)\n", dkron.Version, dkron.Codename)
fmt.Printf("Dkron v%s\n", dkron.Version)
fmt.Printf("Agent Protocol: %d (Understands back to: %d)\n",
serf.ProtocolVersionMax, serf.ProtocolVersionMin)
},
Expand Down
1 change: 0 additions & 1 deletion dkron/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package dkron

var Version = "0.10.3-devel"
var Codename = ""
Loading