Skip to content

Commit

Permalink
Update Fedora packaging workflow and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
bruhhgnik committed Oct 2, 2024
1 parent e9b11be commit 651fab5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 97 deletions.
63 changes: 28 additions & 35 deletions .github/workflows/release-fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,44 @@ name: Release Fedora Package
on:
push:
tags:
- 'v*.*.*' # Trigger the workflow when a new tag is pushed (e.g., v1.0.0)
- 'v*.*.*'

jobs:
build:
runs-on: ubuntu-latest # Using Ubuntu as the host runner, simulating Fedora with Docker
runs-on: ubuntu-latest

steps:
- name: Checkout stone-prover repository
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Fedora environment with Docker
run: |
docker pull fedora:latest # Pull the latest Fedora image
docker run --name fedora-build -d fedora:latest tail -f /dev/null # Start the Fedora container
- name: Install dependencies inside Fedora container
run: |
docker exec -i fedora-build bash -c "dnf update -y && dnf install -y rpm-build gcc make python3-pip wget git"
- name: Set up Docker
uses: docker/setup-buildx-action@v1

- name: Install Bazelisk in Fedora container
- name: Build Fedora container and RPM
run: |
docker exec -i fedora-build bash -c "wget https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
docker exec -i fedora-build bash -c "chmod +x bazelisk-linux-amd64 && mv bazelisk-linux-amd64 /usr/local/bin/bazelisk"
- name: Verify Bazelisk installation
run: docker exec -i fedora-build bash -c "bazelisk version"

- name: Copy and run build.sh inside Fedora container
docker build -t fedora-build -f- . <<EOF
FROM fedora:latest
RUN dnf update -y && dnf install -y rpm-build gcc gcc-c++ make python3-pip wget git
RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64 && \
chmod +x bazelisk-linux-amd64 && \
mv bazelisk-linux-amd64 /usr/local/bin/bazelisk
WORKDIR /build
COPY . .
RUN mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
RUN cp stone-prover.spec ~/rpmbuild/SPECS/
RUN VERSION=\$(echo ${GITHUB_REF#refs/tags/v}) && \
rpmbuild -ba ~/rpmbuild/SPECS/stone-prover.spec --define "version \$VERSION" --define "_topdir \$HOME/rpmbuild"
EOF
- name: Copy RPM from container
run: |
docker cp ./build.sh fedora-build:/build.sh # Copy build.sh to Fedora container
docker exec -i fedora-build bash -c "chmod +x /build.sh && /build.sh" # Run build.sh inside container
- name: Copy stone-prover.spec into Fedora container
run: docker cp ./stone-prover.spec fedora-build:/stone-prover.spec # Copy .spec file into the container

- name: Package RPM inside Fedora container
run: |
docker exec -i fedora-build bash -c "mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}"
docker exec -i fedora-build bash -c "cp /stone-prover.spec ~/rpmbuild/SPECS/stone-prover.spec"
docker exec -i fedora-build bash -c "rpmbuild -ba ~/rpmbuild/SPECS/stone-prover.spec --define '_topdir $HOME/rpmbuild'"
- name: Verify RPM creation
run: docker exec -i fedora-build bash -c "ls -la ~/rpmbuild/RPMS/x86_64/"
docker create --name temp fedora-build
docker cp temp:/root/rpmbuild/RPMS/x86_64 ./rpms
docker rm temp
- name: Upload RPM to GitHub release
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v1
with:
files: ~/rpmbuild/RPMS/x86_64/*.rpm # Upload the RPM package to the release
files: ./rpms/*.rpm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 changes: 9 additions & 43 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,15 @@
#!/bin/bash
# Fix dependencies
set -o xtrace
set -e
set -eo pipefail

# Detect OS and architecture
os=$(uname | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
# Install dependencies
dnf install -y clang gcc-c++ libstdc++-devel libcxx libcxx-devel \
ncurses-compat-libs elfutils-devel gmp-devel python3-devel wget git

# Fedora-specific installation
if [ "$os" == "linux" ] && [ -f /etc/fedora-release ]; then
echo "Detected Fedora"

# Clean and update Fedora packages
sudo dnf clean all
sudo dnf update -y

# Install dependencies
sudo dnf install -y clang gcc-c++ libstdc++-devel libcxx libcxx-devel \
ncurses-compat-libs elfutils-devel gmp-devel python3-devel wget git

# Install Python dependencies
pip install cpplint pytest numpy sympy==1.12.1 cairo-lang==0.12.0

# Install Bazelisk (Bazel wrapper)
wget "https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64"
chmod 755 "bazelisk-linux-amd64"
sudo mv "bazelisk-linux-amd64" /bin/bazelisk

else
echo "$os is either not Fedora or not supported."
exit 1
fi

# Clone the stone-prover repository
git clone https://github.com/baking-bad/stone-prover.git /tmp/stone-prover

# Move into the stone-prover directory
cd /tmp/stone-prover || exit
# Install Python dependencies
pip install cpplint pytest numpy sympy==1.12.1 cairo-lang==0.12.0

# Build with Bazel, specifying C++17 compatibility
bazelisk build --cpu=$arch //... --cxxopt='-std=c++17'

# Run tests
bazelisk test --cpu=$arch //... --cxxopt='-std=c++17'
bazelisk build //... --cxxopt='-std=c++17'

# Create symbolic links for the built binaries
ln -s /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /usr/local/bin/cpu_air_prover
ln -s /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier /usr/local/bin/cpu_air_verifier
# Run tests (comment out if tests are too resource-intensive for CI)
# bazelisk test //... --cxxopt='-std=c++17'
37 changes: 18 additions & 19 deletions stone-prover.spec
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
Name: stone-prover
Version: 1.0.0
Release: 1%{?dist}
Summary: High-performance proof verification tool
Name: stone-prover
Version: %{version}
Release: 1%{?dist}
Summary: High-performance proof verification tool

License: MIT
BuildArch: x86_64
License: MIT
URL: https://github.com/baking-bad/stone-prover
Source0: %{name}-%{version}.tar.gz

# Build dependencies
BuildRequires: gcc, make, bazelisk, rpm-build, python3-pip
Requires: libtinfo5, libdw-dev, libgmp3-dev, python3, python3-numpy, python3-sympy
BuildRequires: gcc gcc-c++ make bazel python3-devel gmp-devel elfutils-libelf-devel
Requires: python3 python3-numpy python3-sympy gmp elfutils-libelf

%description
Stone-prover is a high-performance proof verification tool.

%prep
git clone https://github.com/baking-bad/stone-prover.git /tmp/stone-prover
%autosetup -n %{name}-%{version}

%build
cd /tmp/stone-prover
bazelisk build --cpu=%{_arch} //...
./build.sh

%install
mkdir -p %{buildroot}/usr/local/bin
install -m 755 /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_prover %{buildroot}/usr/local/bin/cpu_air_prover
install -m 755 /tmp/stone-prover/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier %{buildroot}/usr/local/bin/cpu_air_verifier
mkdir -p %{buildroot}%{_bindir}
install -m 755 bazel-bin/src/starkware/main/cpu/cpu_air_prover %{buildroot}%{_bindir}/cpu_air_prover
install -m 755 bazel-bin/src/starkware/main/cpu/cpu_air_verifier %{buildroot}%{_bindir}/cpu_air_verifier

%files
/usr/local/bin/cpu_air_prover
/usr/local/bin/cpu_air_verifier
%{_bindir}/cpu_air_prover
%{_bindir}/cpu_air_verifier

%changelog
* Wed Oct 02 2024 Your Name <[email protected]> - 1.0.0-1
- Initial RPM package for stone-prover.
* Wed Oct 02 2024 Your Name <[email protected]> - %{version}-1
- Initial RPM package for stone-prover.

0 comments on commit 651fab5

Please sign in to comment.