-
Notifications
You must be signed in to change notification settings - Fork 123
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 #644 from deniszh/dzhdanov/pkg-fix
Migrate to nfpm, get rid of gox
- Loading branch information
Showing
6 changed files
with
86 additions
and
97 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
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,20 +29,11 @@ jobs: | |
env: | ||
CGO_ENABLED: 1 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "2.7" # Version range or exact version of a Ruby version to use, using semvers version range syntax. | ||
- name: Install packaging dependencies | ||
run: | | ||
gem install dotenv -v 2.8.1 | ||
gem install rake fpm:1.10.2 package_cloud | ||
GO111MODULE=off go get github.com/mitchellh/gox | ||
- 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 |
---|---|---|
|
@@ -56,19 +56,10 @@ jobs: | |
run: | | ||
make image | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.3' | ||
|
||
- name: Install packaging dependencies | ||
run: | | ||
gem install rake 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: Upload 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:=go-carbon | ||
MAINTAINER:="Roman Lomonosov <[email protected]>" | ||
DESCRIPTION:="Golang implementation of Graphite/Carbon server" | ||
MODULE:=github.com/go-graphite/go-carbon | ||
|
||
|
@@ -21,6 +20,8 @@ endif | |
RPM_VERSION:=$(subst -,_,$(VERSION)) | ||
BUILD ?= $(shell git describe --abbrev=4 --dirty --always --tags) | ||
|
||
SRCS:=$(shell find . -name '*.go') | ||
|
||
all: $(NAME) | ||
|
||
$(NAME): | ||
|
@@ -40,12 +41,14 @@ test: | |
make run-test COMMAND="vet" | ||
make run-test COMMAND="test -race" | ||
|
||
gox-build: | ||
rm -rf out | ||
gox-build: out/$(NAME)-linux-386 out/$(NAME)-linux-amd64 out/$(NAME)-linux-arm64 | ||
|
||
ARCH = 386 amd64 arm64 | ||
out/$(NAME)-linux-%: out $(SRCS) | ||
GOOS=linux GOARCH=$* $(GO) build -ldflags '-X main.BuildVersion=$(VERSION)' -o $@ $(MODULE) | ||
|
||
out: | ||
mkdir -p out | ||
cd out && $(GO) build $(MODULE) && cd .. | ||
gox -os="linux" -arch="amd64" -arch="386" -arch="arm64" -output="out/$(NAME)-{{.OS}}-{{.Arch}}" $(MODULE) | ||
ls -la ./out/ | ||
|
||
clean: | ||
rm -f go-carbon build/* *deb *rpm | ||
|
@@ -67,68 +70,32 @@ package-tree: | |
install -m 0644 deploy/$(NAME).logrotate out/root/etc/logrotate.d/$(NAME) | ||
install -m 0755 deploy/$(NAME).init out/root/etc/init.d/$(NAME) | ||
|
||
fpm-deb: | ||
make fpm-build-deb ARCH=amd64 | ||
make fpm-build-deb ARCH=386 | ||
make fpm-build-deb ARCH=arm64 | ||
|
||
fpm-rpm: | ||
make fpm-build-rpm ARCH=amd64 FILE_ARCH=x86_64 | ||
make fpm-build-rpm ARCH=386 FILE_ARCH=386 | ||
make fpm-build-rpm ARCH=arm64 FILE_ARCH=arm64 | ||
|
||
fpm-build-deb: | ||
make package-tree | ||
chmod 0755 out/$(NAME)-linux-$(ARCH) | ||
fpm -s dir -t deb -n $(NAME) -v $(VERSION) \ | ||
--deb-priority optional --category admin \ | ||
--package $(NAME)_$(VERSION)_$(ARCH).deb \ | ||
--force \ | ||
--deb-compression bzip2 \ | ||
--url https://github.com/go-graphite/$(NAME) \ | ||
--description $(DESCRIPTION) \ | ||
-m $(MAINTAINER) \ | ||
--license "MIT" \ | ||
-a $(ARCH) \ | ||
--before-install deploy/before_install.sh \ | ||
--before-upgrade deploy/before_install.sh \ | ||
--after-install deploy/after_install.sh \ | ||
--after-upgrade deploy/after_install.sh \ | ||
--config-files /etc/ \ | ||
out/root/=/ \ | ||
out/$(NAME)-linux-$(ARCH)=/usr/bin/$(NAME) | ||
|
||
fpm-build-rpm: | ||
make package-tree | ||
chmod 0755 out/$(NAME)-linux-$(ARCH) | ||
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) \ | ||
--package $(NAME)-$(VERSION)-1.$(FILE_ARCH).rpm \ | ||
--force \ | ||
--rpm-compression bzip2 --rpm-os linux \ | ||
--url https://github.com/go-graphite/$(NAME) \ | ||
--description $(DESCRIPTION) \ | ||
-m $(MAINTAINER) \ | ||
--license "MIT" \ | ||
-a $(ARCH) \ | ||
--before-install deploy/before_install.sh \ | ||
--before-upgrade deploy/before_install.sh \ | ||
--after-install deploy/after_install.sh \ | ||
--after-upgrade deploy/after_install.sh \ | ||
--config-files /etc/ \ | ||
out/root/=/ \ | ||
out/$(NAME)-linux-$(ARCH)=/usr/bin/$(NAME) | ||
nfpm-deb: gox-build package-tree | ||
$(MAKE) nfpm-build-deb ARCH=386 | ||
$(MAKE) nfpm-build-deb ARCH=amd64 | ||
$(MAKE) nfpm-build-deb ARCH=arm64 | ||
|
||
nfpm-rpm: gox-build package-tree | ||
$(MAKE) nfpm-build-rpm ARCH=386 | ||
$(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 $* | ||
|
||
packagecloud-push-rpm: $(wildcard $(NAME)-$(RPM_VERSION)-1.*.rpm) | ||
for pkg in $^; do | ||
package_cloud push $(REPO)/el/7 $${pkg} || true | ||
package_cloud push $(REPO)/el/8 $${pkg} || true | ||
package_cloud push $(REPO)/el/9 $${pkg} || true | ||
done | ||
|
||
packagecloud-push-deb: $(wildcard $(NAME)_$(VERSION)_*.deb) | ||
for pkg in $^; do | ||
package_cloud push $(REPO)/ubuntu/xenial $${pkg} || true | ||
package_cloud push $(REPO)/ubuntu/bionic $${pkg} || true | ||
package_cloud push $(REPO)/ubuntu/focal $${pkg} || true | ||
package_cloud push $(REPO)/ubuntu/jammy $${pkg} || true | ||
package_cloud push $(REPO)/ubuntu/noble $${pkg} || true | ||
package_cloud push $(REPO)/debian/stretch $${pkg} || true | ||
package_cloud push $(REPO)/debian/buster $${pkg} || true | ||
package_cloud push $(REPO)/debian/bullseye $${pkg} || 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
name: ${NAME} | ||
description: ${DESCRIPTION} | ||
|
||
# Common packages config | ||
arch: "${ARCH}" # 386, 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" | ||
|
||
scripts: | ||
preinstall: deploy/before_install.sh | ||
postinstall: deploy/after_install.sh | ||
|
||
contents: | ||
- src: out/root/etc/init.d/${NAME} | ||
dst: /etc/init.d/${NAME} | ||
type: config|noreplace | ||
expand: true | ||
- src: out/root/lib/systemd/system/${NAME}.service | ||
dst: /lib/systemd/system/${NAME}.service | ||
type: config|noreplace | ||
expand: true | ||
- src: out/root/etc/logrotate.d/${NAME} | ||
dst: /etc/logrotate.d/${NAME} | ||
type: config|noreplace | ||
expand: true | ||
- src: out/root/etc/${NAME}/storage-schemas.conf | ||
dst: /etc/${NAME}/storage-schemas.conf | ||
type: config|noreplace | ||
expand: true | ||
- src: out/root/etc/${NAME}/storage-aggregation.conf | ||
dst: /etc/${NAME}/storage-aggregation.conf | ||
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 |
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 |
---|---|---|
|
@@ -3,25 +3,18 @@ | |
cd `dirname $0` | ||
ROOT=$PWD | ||
|
||
docker run -ti --rm -v $ROOT:/root/go/src/github.com/go-graphite/go-carbon ubuntu:20.04 bash -c ' | ||
docker run -i -e "DEVEL=${DEVEL:-0}" --rm -v "$ROOT:/root/go/src/github.com/go-graphite/go-carbon" golang bash -e << 'EOF' | ||
cd /root/ | ||
export GO_VERSION=1.17 | ||
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get update | ||
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y rpm ruby ruby-dev wget build-essential | ||
export TZ=Europe/Amsterdam | ||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
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 fpm:1.10.2 package_cloud | ||
go install github.com/mitchellh/gox@latest | ||
ln -s /root/go/bin/gox /usr/bin/gox | ||
go install github.com/goreleaser/nfpm/v2/cmd/[email protected] | ||
cd /root/go/src/github.com/go-graphite/go-carbon | ||
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 |