--- name: Build ostree packages from sid to trixie on: push: branches: [main] workflow_dispatch: jobs: build: name: Build ostree packages runs-on: ubuntu-latest container: image: debian:unstable permissions: contents: read packages: write steps: - name: Setup Debian environment run: | echo "Setting up Debian environment for building..." # Install apt-cacher-ng requirements first echo "Installing apt-cacher-ng requirements..." apt update -y apt install -y curl wget # Try apt-cacher-ng first, fallback to Debian's automatic mirror selection echo "Checking for apt-cacher-ng availability..." # Quick check with timeout to avoid hanging if timeout 10 curl -s --connect-timeout 5 http://192.168.1.101:3142/acng-report.html > /dev/null 2>&1; then echo "✅ apt-cacher-ng is available, configuring proxy sources..." echo "deb http://192.168.1.101:3142/ftp.debian.org/debian unstable main" > /etc/apt/sources.list echo "deb-src http://192.168.1.101:3142/ftp.us.debian.org/debian unstable main" >> /etc/apt/sources.list else echo "⚠️ apt-cacher-ng not available, using standard Debian mirrors..." echo "deb http://deb.debian.org/debian unstable main" > /etc/apt/sources.list echo "deb-src http://deb.debian.org/debian unstable main" >> /etc/apt/sources.list fi # Update package lists apt update -y # Install essential tools first (including git and editor) apt install -y git curl build-essential fakeroot devscripts nano # Set environment variables for dch export DEBEMAIL="build@particle-os.local" export EMAIL="build@particle-os.local" export EDITOR="nano" - name: Checkout code run: | echo "Cloning repository..." git clone https://git.raines.xyz/particle-os/ostree.git /tmp/ostree cd /tmp/ostree git fetch --all git checkout ${{ github.sha || gitea.sha || 'main' }} - name: Download and extract ostree source run: | echo "Downloading ostree source package..." cd /tmp apt source ostree || { echo "apt source ostree failed!"; exit 1; } cd ostree-* || { echo "Failed to change to ostree directory!"; exit 1; } echo "Changed to ostree directory:" pwd ls -la - name: Install build dependencies run: | echo "Installing build dependencies using apt build-dep..." cd /tmp/ostree-* apt build-dep -y . || { echo "apt build-dep failed!"; exit 1; } - name: Add backport revision number run: | echo "Adding backport revision number..." cd /tmp/ostree-* export DEBEMAIL="build@particle-os.local" export EMAIL="build@particle-os.local" export EDITOR="true" # Use dch with --force-distribution to avoid interactive prompts dch --bpo --force-distribution || echo "dch --bpo failed, continuing..." - name: Build packages run: | echo "Building ostree packages using debuild..." cd /tmp/ostree-* echo "Current directory before build:" pwd ls -la echo "Running debuild -b -us -uc..." if debuild -b -us -uc; then echo "Build successful!" else echo "Build failed! Checking for any partial packages..." ls -la ../*.deb 2>/dev/null || echo "No .deb files found after failed build" exit 1 fi echo "Build completed! Checking for generated packages..." ls -la ../*.deb echo "Copying packages to workspace..." cp ../*.deb /workspace/ 2>/dev/null || echo "No .deb files to copy" - name: Upload to Forgejo Debian Registry run: | echo "Uploading to Forgejo Debian Registry..." cd /tmp/ostree-* echo "Files in current directory:" ls -la echo "Looking for .deb files:" ls -la ../*.deb 2>/dev/null || echo "No .deb files found" # Set Forgejo configuration (matching composefs CI) FORGEJO_OWNER="particle-os" FORGEJO_DISTRIBUTION="trixie" FORGEJO_COMPONENT="main" # Upload .deb files to Forgejo Debian Registry for deb_file in ../*.deb; do if [ -f "$deb_file" ]; then echo "Uploading $deb_file to Forgejo Debian Registry..." UPLOAD_URL="https://git.raines.xyz/api/packages/${FORGEJO_OWNER}/debian/pool/${FORGEJO_DISTRIBUTION}/${FORGEJO_COMPONENT}/upload" echo " Upload URL: $UPLOAD_URL" # Use the same pattern as composefs CI if [ -n "${{ secrets.ACCESS_TOKEN }}" ]; then echo " 🔐 Using authentication token..." UPLOAD_RESULT=$(curl -s -w "%{http_code}" \ --user "${FORGEJO_OWNER}:${{ secrets.ACCESS_TOKEN }}" \ --upload-file "$deb_file" \ "$UPLOAD_URL" 2>/dev/null) # Extract HTTP status code (last 3 characters) HTTP_CODE=$(echo "$UPLOAD_RESULT" | tail -c 4) # Extract response body (everything except last 3 characters) RESPONSE_BODY=$(echo "$UPLOAD_RESULT" | head -c -4) echo " HTTP Status: $HTTP_CODE" case $HTTP_CODE in 201) echo " ✅ Package uploaded successfully" ;; 409) echo " ⚠️ Package already exists (version conflict)" ;; 400) echo " ❌ Bad request - package validation failed" ;; *) echo " ❌ Upload failed with HTTP $HTTP_CODE" echo " Response: $RESPONSE_BODY" ;; esac else echo " ⚠️ No ACCESS_TOKEN secret available - skipping upload" echo " 💡 Set ACCESS_TOKEN secret in repository settings to enable automatic publishing" fi fi done echo "🎯 Debian package publishing complete!" echo "📦 Packages are now available in Forgejo Debian Registry" echo "🔧 To install: apt install ostree libostree-1-1"