Skip to content

Commit c8ecaf1

Browse files
committed
Migrate to nfpm, get rid of gox
1 parent 16044e9 commit c8ecaf1

File tree

5 files changed

+70
-90
lines changed

5 files changed

+70
-90
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,11 @@ jobs:
2929
env:
3030
CGO_ENABLED: 1
3131

32-
- name: Set up Ruby
33-
uses: ruby/setup-ruby@v1
34-
with:
35-
ruby-version: '3.3' # Version range or exact version of a Ruby version to use, using semvers version range syntax.
36-
- name: Install packaging dependencies
37-
run: |
38-
gem install fpm package_cloud
39-
cd && go install github.com/mitchellh/gox@v1.0.1
40-
4132
- name: Build packages
4233
id: build
4334
run: |
44-
make gox-build fpm-deb fpm-rpm
35+
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.40.0
36+
make nfpm-deb nfpm-rpm
4537
make sum-files
4638
ARTIFACTS=
4739
# Upload all deb and rpm packages

.github/workflows/tests.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,10 @@ jobs:
9090
# sudo timedatectl set-timezone Etc/GMT+5
9191
# ./e2e-test -config issues/daytime
9292

93-
- name: Set up Ruby
94-
uses: ruby/setup-ruby@v1
95-
with:
96-
ruby-version: '3.3' # Version range or exact version of a Ruby version to use, using semvers version range syntax.
97-
98-
# gem install dotenv -v 2.8.1 # workaroaund for ruby version 2.7.8.225
99-
- name: Install packaging dependencies
100-
run: |
101-
gem install fpm package_cloud
102-
go install github.com/mitchellh/gox@latest
103-
10493
- name: Check packaging
10594
run: |
106-
make DEVEL=1 gox-build fpm-deb fpm-rpm
95+
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.40.0
96+
make DEVEL=1 nfpm-deb nfpm-rpm
10797
make sum-files
10898
10999
- name: Artifact

Makefile

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
NAME:=graphite-clickhouse
2-
MAINTAINER:="Roman Lomonosov <r.lomonosov@gmail.com>"
32
DESCRIPTION:="Graphite cluster backend with ClickHouse support"
43
MODULE:=github.com/lomik/graphite-clickhouse
54

@@ -15,8 +14,6 @@ else
1514
VERSION:=$(shell sh -c 'git describe --always --tags | sed -e "s/^v//i"')
1615
endif
1716

18-
OS ?= linux
19-
2017
SRCS:=$(shell find . -name '*.go')
2118

2219
all: $(NAME)
@@ -57,55 +54,32 @@ test:
5754

5855
e2e-test: $(NAME)
5956
$(GO) build $(MODULE)/cmd/e2e-test
60-
57+
6158
client: $(NAME)
6259
$(GO) build $(MODULE)/cmd/graphite-clickhouse-client
6360

64-
gox-build:
65-
rm -rf out
61+
gox-build: out/$(NAME)-linux-amd64 out/$(NAME)-linux-arm64 out/root/etc/$(NAME)/$(NAME).conf
62+
63+
ARCH = amd64 arm64
64+
out/$(NAME)-linux-%: out $(SRCS)
65+
GOOS=linux GOARCH=$* $(GO) build -ldflags '-X main.BuildVersion=$(VERSION)' -o $@ $(MODULE)
66+
67+
out:
6668
mkdir -p out
67-
gox -ldflags '-X main.BuildVersion=$(VERSION)' -os="$(OS)" -arch="amd64" -arch="arm64" -output="out/$(NAME)-{{.OS}}-{{.Arch}}" github.com/lomik/$(NAME)
68-
ls -la out/
69-
mkdir -p out/root/etc/$(NAME)/
70-
./out/$(NAME)-$(OS)-amd64 -config-print-default > out/root/etc/$(NAME)/$(NAME).conf
71-
72-
fpm-deb:
73-
$(MAKE) fpm-build-deb ARCH=amd64
74-
$(MAKE) fpm-build-deb ARCH=arm64
75-
fpm-rpm:
76-
$(MAKE) fpm-build-rpm ARCH=amd64
77-
$(MAKE) fpm-build-rpm ARCH=arm64
78-
79-
fpm-build-deb:
80-
fpm -s dir -t deb -n $(NAME) -v $(VERSION) \
81-
--deb-priority optional --category admin \
82-
--force \
83-
--url https://github.com/lomik/$(NAME) \
84-
--description $(DESCRIPTION) \
85-
-m $(MAINTAINER) \
86-
--license "MIT" \
87-
-a $(ARCH) \
88-
--config-files /etc/$(NAME)/$(NAME).conf \
89-
--config-files /etc/logrotate.d/$(NAME) \
90-
out/$(NAME)-linux-$(ARCH)=/usr/bin/$(NAME) \
91-
deploy/root/=/ \
92-
out/root/=/
93-
94-
95-
fpm-build-rpm:
96-
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) \
97-
--force \
98-
--rpm-compression bzip2 --rpm-os linux \
99-
--url https://github.com/lomik/$(NAME) \
100-
--description $(DESCRIPTION) \
101-
-m $(MAINTAINER) \
102-
--license "MIT" \
103-
-a $(ARCH) \
104-
--config-files /etc/$(NAME)/$(NAME).conf \
105-
--config-files /etc/logrotate.d/$(NAME) \
106-
out/$(NAME)-linux-$(ARCH)=/usr/bin/$(NAME) \
107-
deploy/root/=/ \
108-
out/root/=/
69+
70+
out/root/etc/$(NAME)/$(NAME).conf: $(NAME)
71+
mkdir -p "$(shell dirname $@)"
72+
./$(NAME) -config-print-default > $@
73+
74+
nfpm-deb: gox-build
75+
$(MAKE) nfpm-build-deb ARCH=amd64
76+
$(MAKE) nfpm-build-deb ARCH=arm64
77+
nfpm-rpm: gox-build
78+
$(MAKE) nfpm-build-rpm ARCH=amd64
79+
$(MAKE) nfpm-build-rpm ARCH=arm64
80+
81+
nfpm-build-%: nfpm.yaml
82+
NAME=$(NAME) DESCRIPTION=$(DESCRIPTION) ARCH=$(ARCH) VERSION_STRING=$(VERSION) nfpm package --packager $*
10983

11084
.ONESHELL:
11185
RPM_VERSION:=$(subst -,_,$(VERSION))

nfpm.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: ${NAME}
3+
description: ${DESCRIPTION}
4+
5+
# Common packages config
6+
arch: "${ARCH}" # amd64, arm64
7+
platform: "linux"
8+
version: "${VERSION_STRING}"
9+
maintainer: &m "Roman Lomonosov <r.lomonosov@gmail.com>"
10+
vendor: *m
11+
homepage: "https://github.com/go-graphite/${NAME}"
12+
license: "MIT"
13+
section: "admin"
14+
priority: "optional"
15+
16+
contents:
17+
- src: deploy/root/usr/
18+
dst: /usr
19+
expand: true
20+
- src: deploy/root/etc/logrotate.d/${NAME}
21+
dst: /etc/logrotate.d/${NAME}
22+
type: config|noreplace
23+
expand: true
24+
- src: out/root/etc/${NAME}/${NAME}.conf
25+
dst: /etc/${NAME}/${NAME}.conf
26+
type: config|noreplace
27+
expand: true
28+
- src: "out/${NAME}-linux-${ARCH}"
29+
dst: /usr/bin/${NAME}
30+
expand: true
31+
# docs
32+
- src: LICENSE
33+
dst: /usr/share/doc/${NAME}/LICENSE
34+
expand: true

packages.sh

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
1-
#!/bin/sh
1+
#!/bin/sh -e
22

3-
cd `dirname $0`
3+
cd "$( dirname "$0" )"
44
ROOT=$PWD
55

6-
docker run -ti --rm -v $ROOT:/root/go/src/github.com/lomik/graphite-clickhouse ubuntu:20.04 bash -c '
6+
docker run -i -e "DEVEL=${DEVEL:-0}" --rm -v "$ROOT:/root/go/src/github.com/lomik/graphite-clickhouse" golang bash -e << 'EOF'
77
cd /root/
8-
export GO_VERSION=1.15.1
98
export TZ=Europe/Moscow
109
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
11-
apt update
12-
DEBIAN_FRONTEND=noninteractive apt install -y rpm ruby ruby-dev wget make git gcc
1310
14-
wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz
15-
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
16-
ln -s /usr/local/go/bin/go /usr/local/bin/go
17-
18-
# newer fpm is broken https://github.com/jordansissel/fpm/issues/1612
19-
gem install rake
20-
gem install fpm:1.10.2
21-
22-
go get github.com/mitchellh/gox
23-
ln -s /root/go/bin/gox /usr/local/bin/gox
11+
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.40.0
2412
2513
cd /root/go/src/github.com/lomik/graphite-clickhouse
2614
27-
make gox-build
28-
make fpm-deb
29-
make fpm-rpm
30-
'
15+
# go reads the VCS state
16+
git config --global --add safe.directory "$PWD"
17+
18+
make nfpm-deb nfpm-rpm
19+
chmod -R a+w *.deb *.rpm out/
20+
EOF

0 commit comments

Comments
 (0)