Skip to content

Commit

Permalink
add containerized build and build rpm (#580)
Browse files Browse the repository at this point in the history
* make: add container build

* make: add build rpm

* release: release rpm

* release: release rpm
  • Loading branch information
rootfs authored Mar 14, 2023
1 parent abbaab9 commit bf6ace0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,21 @@ jobs:
- name: Build RPM package
id: rpm_build
uses: naveenrajm7/rpmbuild@master
env:
VERSION : ${{ github.event.inputs.tag }}
RELEASE: ${{ github.event.inputs.release }}
with:
spec_file: "packaging/rpm/kepler_build.spec"
_VERSION_ : ${{ github.event.inputs.tag }}
_RELEASE_: ${{ github.event.inputs.release }}
_COMMITTER_: ${{ github.event.pull_request.head.sha }}
_TIMESTAMP_: ${{ steps.date.outputs.date }}
_CHANGELOG_: ${{ github.event.head_commit.message }}
run: make build_rpm

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.event.ref, 'refs/tags/')
name: Release
uses: softprops/action-gh-release@master
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.rpm_build.outputs.source_rpm_path }}
asset_name: ${{ steps.rpm_build.outputs.source_rpm_name }}
asset_content_type: ${{ steps.rpm_build.outputs.rpm_content_type }}

files: |
kepler-*.rpm.tar.gz
/root/rpmbuild/RPMs/
create-release-branch:
name: Create release branch
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ else
IMAGE_REPO := quay.io/sustainable_computing_io
endif

ifdef BUILDER_IMAGE
BUILDER_IMAGE := $(BUILD_IMAGE)
else
BUILDER_IMAGE := quay.io/sustainable_computing_io/kepler_builder:ubi-8.6-bcc-0.24-go1.18
endif

ifdef IMAGE_TAG
IMAGE_TAG := $(IMAGE_TAG)
else
Expand Down Expand Up @@ -130,6 +136,16 @@ _build_local: tidy-vendor format
+@GOOS=$(GOOS) GOARCH=$(GOARCH) go build -v -tags ${GO_BUILD_TAGS} \
-o $(CROSS_BUILD_BINDIR)/$(GOOS)_$(GOARCH)/kepler -ldflags $(LDFLAGS) ./cmd/exporter.go

container_build: tidy-vendor format
$(CTR_CMD) run --rm \
-v $(base_dir):/kepler:Z -w /kepler \
-e GOROOT=/usr/local/go -e PATH=$(PATH):/usr/local/go/bin \
$(BUILDER_IMAGE) \
make build

build_rpm:
rpmbuild packaging/rpm/kepler.spec --build-in-place -bb

clean_build_local:
rm -rf $(CROSS_BUILD_BINDIR)

Expand Down
26 changes: 7 additions & 19 deletions packaging/rpm/kepler.spec
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
%undefine _disable_source_fetch

Name: kepler
Version: %{_VERSION_}
Release: %{_RELEASE_}
Version: %{getenv:_VERSION_}
Release: %{getenv:_RELEASE_}
BuildArch: %{getenv:_ARCH_}
Summary: Kepler Binary

License: Apache License 2.0
URL: https://github.com/sustainable-computing-io/kepler/
Source0: https://github.com/sustainable-computing-io/kepler/archive/refs/tags/%{_VERSION_}.tar.gz
Source0: kepler.tar.gz



BuildRequires: gcc
BuildRequires: systemd
BuildRequires: make

Expand All @@ -27,14 +25,6 @@ Requires: bcc
%description
Kubernetes-based Efficient Power Level Exporter

# golang specifics
%global golang_version 1.19

%global debug_package %{nil}
%prep
%autosetup


%build
GOOS=linux
CROSS_BUILD_BINDIR=_output/bin
Expand All @@ -43,7 +33,7 @@ CROSS_BUILD_BINDIR=_output/bin
GOARCH=amd64
%endif

make _build_local GOOS=${GOOS} GOARCH=${GOARCH}
make container_build GOOS=${GOOS} GOARCH=${GOARCH}

cp ./${CROSS_BUILD_BINDIR}/${GOOS}_${GOARCH}/kepler ./_output/kepler

Expand All @@ -55,7 +45,6 @@ install -d %{buildroot}%{_sysconfdir}/kepler/

install -p -m755 ./_output/kepler %{buildroot}%{_bindir}/kepler
install -p -m644 ./packaging/systemd/kepler.service %{buildroot}%{_unitdir}/kepler.service
install -p m755 ./packaging/systemd/kepler.conf %{buildroot}%{_sysconfdir}/kepler/kepler.conf


%post
Expand All @@ -66,9 +55,8 @@ install -p m755 ./packaging/systemd/kepler.conf %{buildroot}%{_sysconfdir}/keple
%license LICENSE
%{_bindir}/kepler
%{_unitdir}/kepler.service
%{buildroot}%{_sysconfdir}/kepler/kepler.conf


%changelog
* %{_TIMESTAMP_} %{_COMMITTER_}
- %{_CHANGELOG_}
* %{getenv:_TIMESTAMP_} %{getenv:_COMMITTER_}
- %{getenv:_CHANGELOG_}
1 change: 0 additions & 1 deletion packaging/systemd/kepler.config

This file was deleted.

0 comments on commit bf6ace0

Please sign in to comment.