diff --git a/.github/workflows/AlmaLinux.yml b/.github/workflows/AlmaLinux.yml index 843c2d0..f1dc990 100644 --- a/.github/workflows/AlmaLinux.yml +++ b/.github/workflows/AlmaLinux.yml @@ -36,7 +36,7 @@ jobs: go-version: '^1.16.7' - name: RPM build MetricCollector - run: rpmbuild -bb --build-in-place --nodeps scripts/cc-metric-collector.spec + run: make rpm # See: https://github.com/actions/download-artifact - name: Save RPM as artifact diff --git a/.github/workflows/runonce.yml b/.github/workflows/runonce.yml index 1160612..be161ea 100644 --- a/.github/workflows/runonce.yml +++ b/.github/workflows/runonce.yml @@ -39,7 +39,7 @@ jobs: # # Job build-1-16 - # Build on latest Ubuntu using golang version 1.17 + # Build on latest Ubuntu using golang version 1.16 # build-1-16: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index b32fb6b..d96b856 100644 --- a/Makefile +++ b/Makefile @@ -56,3 +56,20 @@ vet: staticcheck: go install honnef.co/go/tools/cmd/staticcheck@latest $$(go env GOPATH)/bin/staticcheck ./... + +.ONESHELL: +.PHONY: RPM +RPM: scripts/cc-metric-collector.spec + @WORKSPACE="$${PWD}" + @SPECFILE="$${WORKSPACE}/scripts/cc-metric-collector.spec" + # Setup RPM build tree + @eval $$(rpm --eval "ARCH='%{_arch}' RPMDIR='%{_rpmdir}' SOURCEDIR='%{_sourcedir}' SPECDIR='%{_specdir}' SRPMDIR='%{_srcrpmdir}' BUILDDIR='%{_builddir}'") + @mkdir --parents --verbose "$${RPMDIR}" "$${SOURCEDIR}" "$${SPECDIR}" "$${SRPMDIR}" "$${BUILDDIR}" + # Create source tarball + @VERS=$$(git describe --tags | sed -e 's/^v//g' -e 's/-/+/g') + @PREFIX=$$(rpmspec --query --queryformat "%{name}-%{version}" --define="VERS $${VERS}" "$${SPECFILE}") + @FORMAT="tar.gz" + @SRCFILE="$${SOURCEDIR}/$${PREFIX}.$${FORMAT}" + @git archive --verbose --format "$${FORMAT}" --prefix="$${PREFIX}/" --output="$${SRCFILE}" HEAD + # Build RPM and SRPM + @rpmbuild -ba --define="VERS $${VERS}" --define "_unitdir /usr/lib/systemd/system"--rmsource --clean --nodeps "$${SPECFILE}" \ No newline at end of file