Skip to content

Commit

Permalink
Native packages for Alpine (#56)
Browse files Browse the repository at this point in the history
* Add Alpine packaging workflow and script
* Disable trigger until it's ready
WIP, should be finished

Co-authored-by: Dmitry Mirgaleev <[email protected]>
  • Loading branch information
0xdevcollins and dmirgaleev authored Oct 8, 2024
1 parent e235147 commit c7948d6
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release-alpine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build Alpine Package

on:
# push:
# tags:
# - 'v*'

jobs:
build:
runs-on: ubuntu-latest
container:
image: alpine:latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install dependencies
run: |
apk add --no-cache \
alpine-sdk \
cmake \
git \
curl \
bash \
build-base \
boost-dev \
gmp-dev \
abuild
- name: Create Alpine package
run: |
chmod +x ./package_alpine.sh
./package_alpine.sh ${{ github.ref_name }}
- name: Upload Alpine package
uses: actions/upload-artifact@v3
with:
name: stone-prover-alpine-package
path: /tmp/packages/main/x86_64/*.apk

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: /tmp/packages/main/x86_64/stone-prover-*.apk
asset_name: stone-prover-alpine-${{ github.ref }}.apk
asset_content_type: application/vnd.alpine.linux.apk
71 changes: 71 additions & 0 deletions package_alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
set -e

echo "Starting package creation process..."
echo "Checking necessary dependencies..."

# Ensure necessary dependencies are installed
apk add --no-cache alpine-sdk build-base

# Define the binary paths
PROVER_PATH="/usr/local/bin/cpu_air_prover"
VERIFIER_PATH="/usr/local/bin/cpu_air_verifier"

# Check if the binaries exist
if [ ! -f "$PROVER_PATH" ]; then
echo "Error: cpu_air_prover not found in /usr/local/bin. Please ensure the binary is built."
exit 1
fi

if [ ! -f "$VERIFIER_PATH" ]; then
echo "Error: cpu_air_verifier not found in /usr/local/bin. Please ensure the binary is built."
exit 1
fi

# Log found binaries
echo "Found cpu_air_prover at $PROVER_PATH"
echo "Found cpu_air_verifier at $VERIFIER_PATH"

# Create a temporary directory for the package
echo "Creating temporary directories..."
mkdir -p /tmp/stone-prover/ALPINE || { echo "Failed to create directory /tmp/stone-prover/ALPINE"; exit 1; }
mkdir -p /tmp/stone-prover/usr/bin || { echo "Failed to create directory /tmp/stone-prover/usr/bin"; exit 1; }

TAG=$1
echo "Using tag $TAG"

# Copy binaries to the appropriate directory
echo "Copying binaries to package directories..."
cp "$PROVER_PATH" /tmp/stone-prover/usr/bin/
cp "$VERIFIER_PATH" /tmp/stone-prover/usr/bin/

# Create the APKBUILD file for Alpine package creation
echo "Creating APKBUILD file..."
cat <<EOF > /tmp/stone-prover/APKBUILD
# Contributor: Baking Bad <[email protected]>
# Maintainer: Baking Bad <[email protected]>
pkgname=stone-prover
pkgver=$(echo $TAG | cut -c 2-)
pkgrel=0
pkgdesc="Stone prover alpine package"
arch="x86_64"
license="GPL-3.0"
source=""
builddir="/tmp/stone-prover"
package() {
mkdir -p "\$pkgdir/usr/bin"
install -Dm755 "\$builddir"/usr/bin/cpu_air_prover "\$pkgdir"/usr/bin/cpu_air_prover
install -Dm755 "\$builddir"/usr/bin/cpu_air_verifier "\$pkgdir"/usr/bin/cpu_air_verifier
}
EOF

# Build the Alpine package using abuild
echo "Building the package using abuild..."
cd /tmp/stone-prover || { echo "Failed to change directory to /tmp/stone-prover"; exit 1; }
abuild checksum || { echo "abuild checksum failed"; exit 1; }
abuild -r || { echo "abuild build failed"; exit 1; }

# Output the built package location
echo "Alpine package built successfully."
echo "Package location: /tmp/packages/main/x86_64/stone-prover-*.apk"

0 comments on commit c7948d6

Please sign in to comment.