-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from go-graphite/nfpm
Migrate packages building to nfpm and pure go build
- Loading branch information
Showing
5 changed files
with
70 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,19 +29,11 @@ jobs: | |
env: | ||
CGO_ENABLED: 1 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.3' # Version range or exact version of a Ruby version to use, using semvers version range syntax. | ||
- name: Install packaging dependencies | ||
run: | | ||
gem install fpm package_cloud | ||
cd && go install github.com/mitchellh/[email protected] | ||
- name: Build packages | ||
id: build | ||
run: | | ||
make gox-build fpm-deb fpm-rpm | ||
go install github.com/goreleaser/nfpm/v2/cmd/[email protected] | ||
make nfpm-deb nfpm-rpm | ||
make sum-files | ||
ARTIFACTS= | ||
# Upload all deb and rpm packages | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,19 +75,10 @@ jobs: | |
# env: | ||
# CGO_ENABLED: 1 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.3' # Version range or exact version of a Ruby version to use, using semvers version range syntax. | ||
|
||
- name: Install packaging dependencies | ||
run: | | ||
gem install fpm package_cloud | ||
go install github.com/mitchellh/gox@latest | ||
- name: Check packaging | ||
run: | | ||
make DEVEL=1 gox-build fpm-deb fpm-rpm | ||
go install github.com/goreleaser/nfpm/v2/cmd/[email protected] | ||
make DEVEL=1 nfpm-deb nfpm-rpm | ||
make sum-files | ||
- name: Artifact | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
NAME:=carbon-clickhouse | ||
MAINTAINER:="Roman Lomonosov <[email protected]>" | ||
DESCRIPTION:="Graphite metrics receiver with ClickHouse as storage" | ||
MODULE:=github.com/lomik/carbon-clickhouse | ||
|
||
|
@@ -36,51 +35,29 @@ e2e-test: $(NAME) | |
test: | ||
$(GO) test -race ./... | ||
|
||
gox-build: | ||
rm -rf out | ||
gox-build: out/$(NAME)-linux-amd64 out/$(NAME)-linux-arm64 out/root/etc/$(NAME)/$(NAME).conf | ||
|
||
ARCH = amd64 arm64 | ||
out/$(NAME)-linux-%: out $(SRCS) | ||
GOOS=linux GOARCH=$* $(GO) build -o $@ $(MODULE) | ||
|
||
out: | ||
mkdir -p out | ||
gox -os="linux" -arch="amd64" -arch="arm64" -output="out/$(NAME)-{{.OS}}-{{.Arch}}" github.com/lomik/$(NAME) | ||
ls -la out/ | ||
mkdir -p out/root/etc/$(NAME)/ | ||
./out/$(NAME)-linux-amd64 -config-print-default > out/root/etc/$(NAME)/$(NAME).conf | ||
|
||
fpm-deb: | ||
$(MAKE) fpm-build-deb ARCH=amd64 | ||
$(MAKE) fpm-build-deb ARCH=arm64 | ||
fpm-rpm: | ||
$(MAKE) fpm-build-rpm ARCH=amd64 | ||
$(MAKE) fpm-build-rpm ARCH=arm64 | ||
|
||
fpm-build-deb: | ||
fpm -s dir -t deb -n $(NAME) -v $(VERSION) \ | ||
--deb-priority optional --category admin \ | ||
--force \ | ||
--url https://github.com/lomik/$(NAME) \ | ||
--description $(DESCRIPTION) \ | ||
-m $(MAINTAINER) \ | ||
--license "MIT" \ | ||
-a $(ARCH) \ | ||
--config-files /etc/$(NAME)/$(NAME).conf \ | ||
--config-files /etc/logrotate.d/$(NAME) \ | ||
out/$(NAME)-linux-$(ARCH)=/usr/bin/$(NAME) \ | ||
deploy/root/=/ \ | ||
out/root/=/ | ||
|
||
|
||
fpm-build-rpm: | ||
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) \ | ||
--force \ | ||
--rpm-compression bzip2 --rpm-os linux \ | ||
--url https://github.com/lomik/$(NAME) \ | ||
--description $(DESCRIPTION) \ | ||
-m $(MAINTAINER) \ | ||
--license "MIT" \ | ||
-a $(ARCH) \ | ||
--config-files /etc/$(NAME)/$(NAME).conf \ | ||
--config-files /etc/logrotate.d/$(NAME) \ | ||
out/$(NAME)-linux-$(ARCH)=/usr/bin/$(NAME) \ | ||
deploy/root/=/ \ | ||
out/root/=/ | ||
|
||
|
||
out/root/etc/$(NAME)/$(NAME).conf: $(NAME) | ||
mkdir -p "$(shell dirname $@)" | ||
./$(NAME) -config-print-default > $@ | ||
|
||
nfpm-deb: gox-build | ||
$(MAKE) nfpm-build-deb ARCH=amd64 | ||
$(MAKE) nfpm-build-deb ARCH=arm64 | ||
nfpm-rpm: gox-build | ||
$(MAKE) nfpm-build-rpm ARCH=amd64 | ||
$(MAKE) nfpm-build-rpm ARCH=arm64 | ||
|
||
nfpm-build-%: nfpm.yaml | ||
NAME=$(NAME) DESCRIPTION=$(DESCRIPTION) ARCH=$(ARCH) VERSION_STRING=$(VERSION) nfpm package --packager $* | ||
|
||
.ONESHELL: | ||
RPM_VERSION:=$(subst -,_,$(VERSION)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
name: ${NAME} | ||
description: ${DESCRIPTION} | ||
|
||
# Common packages config | ||
arch: "${ARCH}" # amd64, arm64 | ||
platform: "linux" | ||
version: "${VERSION_STRING}" | ||
maintainer: &m "Roman Lomonosov <[email protected]>" | ||
vendor: *m | ||
homepage: "https://github.com/go-graphite/${NAME}" | ||
license: "MIT" | ||
section: "admin" | ||
priority: "optional" | ||
|
||
contents: | ||
- src: deploy/root/usr/ | ||
dst: /usr | ||
expand: true | ||
- src: deploy/root/etc/logrotate.d/${NAME} | ||
dst: /etc/logrotate.d/${NAME} | ||
type: config|noreplace | ||
expand: true | ||
- src: out/root/etc/${NAME}/${NAME}.conf | ||
dst: /etc/${NAME}/${NAME}.conf | ||
type: config|noreplace | ||
expand: true | ||
- src: "out/${NAME}-linux-${ARCH}" | ||
dst: /usr/bin/${NAME} | ||
expand: true | ||
# docs | ||
- src: LICENSE | ||
dst: /usr/share/doc/${NAME}/LICENSE | ||
expand: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
#!/bin/sh | ||
#!/bin/sh -e | ||
|
||
cd `dirname $0` | ||
cd "$( dirname "$0" )" | ||
ROOT=$PWD | ||
|
||
docker run -ti -e "DEVEL=${DEVEL:-0}" --rm -v $ROOT:/root/go/src/github.com/lomik/carbon-clickhouse ubuntu:20.04 bash -c ' | ||
docker run -i -e "DEVEL=${DEVEL:-0}" --rm -v "$ROOT:/root/go/src/github.com/lomik/carbon-clickhouse" golang bash -e << 'EOF' | ||
cd /root/ | ||
export GO_VERSION=1.15.1 | ||
export TZ=Europe/Moscow | ||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
apt update | ||
DEBIAN_FRONTEND=noninteractive apt install -y rpm ruby ruby-dev wget make git gcc | ||
wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | ||
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz | ||
ln -s /usr/local/go/bin/go /usr/local/bin/go | ||
# newer fpm is broken https://github.com/jordansissel/fpm/issues/1612 | ||
gem install rake | ||
gem install fpm:1.10.2 | ||
go get github.com/mitchellh/gox | ||
ln -s /root/go/bin/gox /usr/local/bin/gox | ||
go install github.com/goreleaser/nfpm/v2/cmd/[email protected] | ||
cd /root/go/src/github.com/lomik/carbon-clickhouse | ||
make gox-build | ||
make fpm-deb | ||
make fpm-rpm | ||
' | ||
# go reads the VCS state | ||
git config --global --add safe.directory "$PWD" | ||
make nfpm-deb nfpm-rpm | ||
chmod -R a+w *.deb *.rpm out/ | ||
EOF |