diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d83b276..66dc6a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,9 +9,9 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Build - run: go build -v ./cmd/greggd/ + run: make build - name: Test - run: go test -v ./... + run: make test - name: Save artifact uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa83774..a10e9a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,27 +11,22 @@ jobs: # No shallow clone with: fetch-depth: 0 - - name: Export release vars - id: vars - shell: bash - run: | - echo "::set-output name=version::$(git describe --tags --abbrev=0)" - echo "::set-output name=release::$(git rev-parse --short HEAD)" - name: Build - run: go build -v ./cmd/greggd/ + run: make test - name: Test - run: go test -v ./... + run: make test - name: Build RPM - env: - VERSION: ${{ steps.vars.outputs.version }} - RELEASE: ${{ steps.vars.outputs.release }} run: | - envsubst < build/nfpm-template.yaml > build/nfpm.yaml - nfpm -f build/nfpm.yaml pkg --packager rpm + make srpm + make rpm + cp ~/rpmbuild/SRPMS/greggd*.rpm . + cp ~/rpmbuild/RPMS/*/greggd*.rpm . - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: - files: greggd*.rpm + files: | + greggd*.rpm + greggd*.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5b92802 --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +VERSION != git describe --tags --abbrev=0 +RELEASE != git rev-parse --short HEAD +PREFIX := /usr +GREGGD_ARCHIVE := greggd-$(VERSION)-$(RELEASE).tar.gz + +.PHONY: build +build: + go build -v ./cmd/greggd/ + +.PHONY: test +test: + go test -v ./... + +.PHONY: install +install: greggd + mkdir -p $(DESTDIR)/$(PREFIX)/sbin/ + mkdir -p $(DESTDIR)/$(PREFIX)/share/greggd/{c,doc}/ + mkdir -p $(DESTDIR)/$(PREFIX)/lib/systemd/system/ + install -m 0755 ./greggd $(DESTDIR)/$(PREFIX)/sbin/ + install -m 0644 ./README.md $(DESTDIR)/$(PREFIX)/share/greggd/doc/ + install -m 0644 ./LICENSE.md $(DESTDIR)/$(PREFIX)/share/greggd/doc/ + install -m 0644 ./csrc/*.c $(DESTDIR)/$(PREFIX)/share/greggd/c/ + install -m 0644 ./init/greggd.service $(DESTDIR)/$(PREFIX)/lib/systemd/system/ + +.PHONY: clean +clean: + rm ./greggd + +.PHONY: uninstall +uninstall: + rm -f $(DESTDIR)/$(PREFIX)/sbin/greggd + mkdir -p $(DESTDIR)/$(PREFIX)/share/greggd/{c,doc}/ + mkdir -p $(DESTDIR)/$(PREFIX)/lib/systemd/system/greggd.service + +.PHONY: archive +archive: + git archive -o greggd-$(VERSION)-$(RELEASE).tar.gz HEAD + +.PHONY: srpm +srpm: + mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + make archive + cp $(GREGGD_ARCHIVE) ~/rpmbuild/SOURCES + rpmbuild -bs ./build/greggd.spec + +.PHONY: rpm +rpm: + mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} + rpmbuild -bb ./build/greggd.spec diff --git a/build/Dockerfile b/build/Dockerfile index 6e1e6ae..08d9954 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -9,10 +9,7 @@ LABEL name="greggd-devel" \ version="centos8.3-297" RUN dnf install --enablerepo=powertools -y \ - @development git golang kernel-devel bcc-devel; \ + @development git golang kernel-devel bcc-devel rpm-build make; \ yum clean all -RUN \ - curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.5.1/nfpm_amd64.rpm; \ - rpm -i nfpm_amd64.rpm; rm nfpm_amd64.rpm CMD ["/bin/bash"] diff --git a/build/greggd.spec b/build/greggd.spec new file mode 100644 index 0000000..7240518 --- /dev/null +++ b/build/greggd.spec @@ -0,0 +1,39 @@ +%global gitversion %(git describe --tags --abbrev=0) +%global gitrelease %(git rev-parse --short HEAD) +%define debug_package %{nil} +Name: greggd +Version: %{gitversion} +Release: %{gitrelease}%{?dist} +Summary: Global runtime for eBPF-enabled gathering (w/ gumption) daemon + +License: ASL 2.0 +URL: https://github.com/olcf/%{name} +Source0: https://github.com/olcf/%{name}/release/%{name}-%{gitversion}-%{gitrelease}.tar.gz + +BuildRequires: golang +BuildRequires: bcc +BuildRequires: bcc-devel +BuildRequires: git +Requires: bcc + +%description +System daemon wrapping the BPF Compiler Collection to compile and load BPF +programs into the kernel, and output data to metric reporting tools via a +unix-socket. + +%prep +%setup -q -c %{name}-%{gitversion}-%{gitrelease} + +%build +make build + +%install +make DESTDIR=%{buildroot} PREFIX=%{_prefix} install + +%files +%{_prefix}/sbin/%{name} +%{_prefix}/lib/systemd/system/%{name}.service +%{_prefix}/share/%{name}/c/ +%doc %{_prefix}/share/%{name}/doc/ + +%changelog