Skip to content

Commit bf6ace0

Browse files
authored
add containerized build and build rpm (#580)
* make: add container build * make: add build rpm * release: release rpm * release: release rpm
1 parent abbaab9 commit bf6ace0

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

.github/workflows/release.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,21 @@ jobs:
6262
6363
- name: Build RPM package
6464
id: rpm_build
65-
uses: naveenrajm7/rpmbuild@master
6665
env:
67-
VERSION : ${{ github.event.inputs.tag }}
68-
RELEASE: ${{ github.event.inputs.release }}
69-
with:
70-
spec_file: "packaging/rpm/kepler_build.spec"
66+
_VERSION_ : ${{ github.event.inputs.tag }}
67+
_RELEASE_: ${{ github.event.inputs.release }}
68+
_COMMITTER_: ${{ github.event.pull_request.head.sha }}
69+
_TIMESTAMP_: ${{ steps.date.outputs.date }}
70+
_CHANGELOG_: ${{ github.event.head_commit.message }}
71+
run: make build_rpm
7172

72-
- name: Upload Release Asset
73-
id: upload-release-asset
74-
uses: actions/upload-release-asset@v1
75-
env:
76-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
- if: startsWith(github.event.ref, 'refs/tags/')
74+
name: Release
75+
uses: softprops/action-gh-release@master
7776
with:
78-
upload_url: ${{ steps.create_release.outputs.upload_url }}
79-
asset_path: ${{ steps.rpm_build.outputs.source_rpm_path }}
80-
asset_name: ${{ steps.rpm_build.outputs.source_rpm_name }}
81-
asset_content_type: ${{ steps.rpm_build.outputs.rpm_content_type }}
82-
77+
files: |
78+
kepler-*.rpm.tar.gz
79+
/root/rpmbuild/RPMs/
8380
8481
create-release-branch:
8582
name: Create release branch

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ else
1818
IMAGE_REPO := quay.io/sustainable_computing_io
1919
endif
2020

21+
ifdef BUILDER_IMAGE
22+
BUILDER_IMAGE := $(BUILD_IMAGE)
23+
else
24+
BUILDER_IMAGE := quay.io/sustainable_computing_io/kepler_builder:ubi-8.6-bcc-0.24-go1.18
25+
endif
26+
2127
ifdef IMAGE_TAG
2228
IMAGE_TAG := $(IMAGE_TAG)
2329
else
@@ -130,6 +136,16 @@ _build_local: tidy-vendor format
130136
+@GOOS=$(GOOS) GOARCH=$(GOARCH) go build -v -tags ${GO_BUILD_TAGS} \
131137
-o $(CROSS_BUILD_BINDIR)/$(GOOS)_$(GOARCH)/kepler -ldflags $(LDFLAGS) ./cmd/exporter.go
132138

139+
container_build: tidy-vendor format
140+
$(CTR_CMD) run --rm \
141+
-v $(base_dir):/kepler:Z -w /kepler \
142+
-e GOROOT=/usr/local/go -e PATH=$(PATH):/usr/local/go/bin \
143+
$(BUILDER_IMAGE) \
144+
make build
145+
146+
build_rpm:
147+
rpmbuild packaging/rpm/kepler.spec --build-in-place -bb
148+
133149
clean_build_local:
134150
rm -rf $(CROSS_BUILD_BINDIR)
135151

packaging/rpm/kepler.spec

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
%undefine _disable_source_fetch
22

33
Name: kepler
4-
Version: %{_VERSION_}
5-
Release: %{_RELEASE_}
4+
Version: %{getenv:_VERSION_}
5+
Release: %{getenv:_RELEASE_}
6+
BuildArch: %{getenv:_ARCH_}
67
Summary: Kepler Binary
78

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

12-
13-
14-
BuildRequires: gcc
1513
BuildRequires: systemd
1614
BuildRequires: make
1715

@@ -27,14 +25,6 @@ Requires: bcc
2725
%description
2826
Kubernetes-based Efficient Power Level Exporter
2927

30-
# golang specifics
31-
%global golang_version 1.19
32-
33-
%global debug_package %{nil}
34-
%prep
35-
%autosetup
36-
37-
3828
%build
3929
GOOS=linux
4030
CROSS_BUILD_BINDIR=_output/bin
@@ -43,7 +33,7 @@ CROSS_BUILD_BINDIR=_output/bin
4333
GOARCH=amd64
4434
%endif
4535

46-
make _build_local GOOS=${GOOS} GOARCH=${GOARCH}
36+
make container_build GOOS=${GOOS} GOARCH=${GOARCH}
4737

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

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

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

6049

6150
%post
@@ -66,9 +55,8 @@ install -p m755 ./packaging/systemd/kepler.conf %{buildroot}%{_sysconfdir}/keple
6655
%license LICENSE
6756
%{_bindir}/kepler
6857
%{_unitdir}/kepler.service
69-
%{buildroot}%{_sysconfdir}/kepler/kepler.conf
7058

7159

7260
%changelog
73-
* %{_TIMESTAMP_} %{_COMMITTER_}
74-
- %{_CHANGELOG_}
61+
* %{getenv:_TIMESTAMP_} %{getenv:_COMMITTER_}
62+
- %{getenv:_CHANGELOG_}

packaging/systemd/kepler.config

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)