Skip to content

Commit 2c7bddc

Browse files
author
Daniele Rondina
committed
Add goreleaser integration
1 parent 690168f commit 2c7bddc

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

.goreleaser.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
builds:
2+
- env:
3+
- CGO_ENABLED=0
4+
goos:
5+
- linux
6+
goarch:
7+
- amd64
8+
- arm
9+
- arm64
10+
11+
goarm:
12+
- 6
13+
- 7
14+
15+
ldflags:
16+
- >-
17+
-s -w -X github.com/MottainaiCI/simplestreams-builder/cmd.BuildTime={{.Date}}
18+
-X github.com/MottainaiCI/simplestreams-builder/cmd.BuildCommit={{.Commit}}
19+
20+
archives:
21+
- format: binary
22+
name_template: simplestreams-builder-{{ .Tag }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}
23+
source:
24+
enabled: true
25+
name_template: '{{ .ProjectName }}-{{ .Tag }}-source'
26+
checksum:
27+
name_template: '{{ .ProjectName }}-{{ .Tag }}-checksums.txt'
28+
snapshot:
29+
name_template: "{{ .Tag }}-next"
30+
changelog:
31+
sort: asc
32+
filters:
33+
exclude:
34+
- '^docs:'
35+
- '^test:'
36+
- '^scripts:'
37+
- '^contrib'

Makefile

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
# go tool nm ./luet | grep Commit
3+
override LDFLAGS += -X "github.com/MottainaiCI/simplestreams-builder/cmd.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
4+
override LDFLAGS += -X "github.com/MottainaiCI/simplestreams-builder/cmd.BuildCommit=$(shell git rev-parse HEAD)"
5+
6+
NAME ?= lxd-compose
7+
PACKAGE_NAME ?= $(NAME)
8+
REVISION := $(shell git rev-parse --short HEAD || echo dev)
9+
VERSION := $(shell git describe --tags || echo $(REVISION))
10+
VERSION := $(shell echo $(VERSION) | sed -e 's/^v//g')
11+
BUILD_PLATFORMS ?= -osarch="linux/amd64" -osarch="linux/386" -osarch="linux/arm"
12+
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
13+
14+
.PHONY: all
15+
all: deps build
16+
17+
.PHONY: fmt
18+
fmt:
19+
go fmt ./...
20+
21+
.PHONY: test
22+
test:
23+
GO111MODULE=off go get github.com/onsi/ginkgo/ginkgo
24+
GO111MODULE=off go get github.com/onsi/gomega/...
25+
ginkgo -race -r -flakeAttempts 3 ./...
26+
27+
.PHONY: coverage
28+
coverage:
29+
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
30+
31+
.PHONY: test-coverage
32+
test-coverage:
33+
scripts/ginkgo.coverage.sh --codecov
34+
35+
.PHONY: clean
36+
clean:
37+
rm -rf release/
38+
39+
.PHONY: deps
40+
deps:
41+
go env
42+
# Installing dependencies...
43+
GO111MODULE=off go get golang.org/x/lint/golint
44+
GO111MODULE=off go get github.com/mitchellh/gox
45+
GO111MODULE=off go get golang.org/x/tools/cmd/cover
46+
GO111MODULE=off go get github.com/onsi/ginkgo/ginkgo
47+
GO111MODULE=off go get github.com/onsi/gomega/...
48+
49+
.PHONY: build
50+
build:
51+
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)'
52+
53+
.PHONY: build-small
54+
build-small:
55+
@$(MAKE) LDFLAGS+="-s -w" build
56+
upx --brute -1 $(NAME)
57+
58+
.PHONY: lint
59+
lint:
60+
golint ./... | grep -v "be unexported"
61+
62+
.PHONY: vendor
63+
vendor:
64+
go mod vendor
65+
66+
.PHONY: goreleaser-snapshot
67+
goreleaser-snapshot:
68+
rm -rf dist/ || true
69+
goreleaser release --debug --skip-publish --skip-validate
70+
71+
.PHONY: multiarch-build
72+
multiarch-build:
73+
CGO_ENABLED=0 gox $(BUILD_PLATFORMS) -ldflags '$(LDFLAGS)' -output="release/$(NAME)-$(VERSION)-{{.OS}}-{{.Arch}}"

0 commit comments

Comments
 (0)