Skip to content

Commit

Permalink
feat(ci): modified action to build rpm
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeCyp committed Sep 20, 2024
1 parent 04325d8 commit 607c8dd
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 27 deletions.
50 changes: 43 additions & 7 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- ci/create-rpm-package
pull_request:
env:
os: RHEL
Expand Down Expand Up @@ -41,17 +42,29 @@ jobs:
name: ${{ needs.parsing.outputs.compname }}
compvers: ${{ needs.parsing.outputs.compvers }}
arch: ${{ needs.parsing.outputs.comparch }}

container:
image: fedora:40
steps:
- uses: actions/checkout@v4

- name: Install RPM
run: sudo apt update && sudo apt upgrade -y && sudo apt install rpm

run: |
sudo dnf install rust cargo -y -v
export PATH=$PATH:$HOME/.cargo/bin/
sudo dnf install rpm-build rpmdevtools -y -v
sudo dnf install cargo-rpm-macros -y -v
cargo install cargo-lock2rpmprovides
PROTOC_ZIP=protoc-28.0-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v28.0/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
- name: Setup for alumet
run: |
mkdir -p alumet
- name: Install alumet
- name: Checkout alumet
uses: actions/checkout@v4
with:
repository: alumet-dev/alumet
Expand All @@ -63,8 +76,31 @@ jobs:
env:
build_dir: "$(pwd)/build"
run: |
echo $(pwd)
ls -al
mkdir -p ${{ env.build_dir }}/SOURCES
tar --exclude=".[^/]*" --exclude="./build" --transform 's|.|alumet|' -zcvf ${{ env.build_dir }}/SOURCES/alumet.tar.gz .
rpmbuild -ba --define "_topdir ${{ env.build_dir }}" specs/alumet.spec
rpmbuild -ba -vv --define "_topdir ${{ env.build_dir }}" --define "release ${{env.os}}${{env.os_version}}" specs/alumet.spec
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.name }}-${{env.os}}${{env.os_version}}.${{ env.arch }}.rpm
path: ./build/RPMS/${{ env.arch }}/alumet-${{ env.compvers }}-${{env.os}}${{env.os_version}}.${{ env.arch }}.rpm

# publish:
# runs-on: ubuntu-latest
# needs:
# - packaging
# env:
# name: ${{ needs.parsing.outputs.compname }}
# compvers: ${{ needs.parsing.outputs.compvers }}
# arch: ${{ needs.parsing.outputs.comparch }}

# steps:
# - name: Checkout git repository
# uses: actions/checkout@v4

# - name: Download artifact
# uses: actions/download-artifact@v4
# with:
# name: ${{ env.name }}-${{env.os}}${{env.os_version}}.${{ env.arch }}.rpm

67 changes: 47 additions & 20 deletions specs/alumet.spec
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
Name: ALUMET
Name: alumet
Version: 0.5.0
Release: 1%{?dist}
Release: %{release}
Summary: A tool for measuring the energy consumption and performance metrics
License: EUPL
Url: https://github.com/alumet-dev/alumet
Source: %{name}_v%{version}.tar.gz
Source: %{name}.tar.gz
BuildArch: x86_64

%package alumet-local-agent
Summary: alumet-local-agent package
%description alumet-local-agent
This package contains the alumet app agent.

# Disable this line if you wish to support all platforms.
# In most situations, you will likely only target tier1 arches for user facing components.
%package alumet-relay-server
Summary: alumet-relay-server package
%description alumet-relay-server
This package contains the alumet alumet-relay-server.

%package alumet-relay-client
Summary: alumet-relay-client package
%description alumet-relay-client
This package contains the alumet alumet-relay-client.

%description
Customizable and efficient tool for measuring the energy consumption and performance metrics of software on HPC, Cloud and Edge devices.
Expand All @@ -19,21 +30,37 @@ Customizable and efficient tool for measuring the energy consumption and perform


%build
%{cargo_build}

cd alumet/app-agent
json=$(CARGO_TARGET_DIR=%{_builddir} cargo build --bins --release --all-features --message-format=json-render-diagnostics "$@")
executables=$(echo "$json" | grep -oP '"executable":"\K[^"]+' | tr '\n' ' ')
echo "$executables" > %{_builddir}/executables.txt



%install
pwd
ls -al
cd app-agent
%{cargo_install}
pwd
ls -al
mkdir -p %{buildroot}%{_bindir}
ls -al %{_builddir}
ls -al %{_builddir}/release/
ls -al %{_builddir}/release/build/
ls -al %{_builddir}/release/incremental
ls -al %{buildroot}%{_bindir}
executables=$(cat %{_builddir}/executables.txt)
for binary in $executables; do
filename=$(basename "$binary")
install -D -m 0755 "$binary" %{buildroot}%{_bindir}/"$filename"
done


%files alumet-local-agent
%{_bindir}/alumet-local-agent

%files alumet-relay-server
%{_bindir}/alumet-relay-server

%files alumet-relay-client
%{_bindir}/alumet-relay-client


%files
# %license LICENSE
%{_bindir}/alumet-agent


%clean
ù{cargo}
%changelog
* Wed Sep 18 2024 Cyprien [email protected] - 0.0.1
- Initial package

0 comments on commit 607c8dd

Please sign in to comment.