name: Build apt-ostree Package # ⚠️ IMPORTANT: Each repository needs its own FORGEJO_TOKEN secret! # # To set up this workflow in a new repository: # 1. Go to repository settings: https://git.raines.xyz/OWNER/REPO/settings # 2. Find "Secrets" or "Repository secrets" section # 3. Add new secret: # - Name: FORGEJO_TOKEN # - Value: Your Personal Access Token with repo and write:packages permissions # 4. The token needs these scopes: # - repo (Full control of private repositories) # - write:packages (Write packages) # - read:packages (Read packages) # # This workflow will fail with "FORGEJO_TOKEN is not set" if the secret is missing. on: push: branches: [ main, master ] pull_request: branches: [ main, master ] workflow_dispatch: env: DEBIAN_VERSION: "stable" APT_OSTREE_VERSION: "0.1.0" jobs: build-apt-ostree: name: Build apt-ostree Package runs-on: ubuntu-latest container: image: debian:latest steps: - name: Setup build environment shell: bash run: | # Update package lists apt update -y # Install essential build tools apt install -y git curl pkg-config build-essential gnupg wget # Install Rust using rustup to get the latest version curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y . ~/.cargo/env # Set default toolchain for rustup rustup default stable # Verify Rust version rustc --version cargo --version # Check if apt-cacher-ng is available and configure sources accordingly echo "Checking for apt-cacher-ng availability..." if 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..." # Configure apt-cacher-ng proxy sources cat > /etc/apt/sources.list.d/apt-cacher-ng.list << 'EOF' deb http://192.168.1.101:3142/ftp.debian.org/debian stable main contrib non-free deb-src http://192.168.1.101:3142/ftp.debian.org/debian stable main contrib non-free deb http://192.168.1.101:3142/HTTPS///get.docker.com/ubuntu docker main EOF # Update package lists with proxy sources apt update -y else echo "⚠️ apt-cacher-ng not available, using standard Debian sources..." # Use standard Debian sources cat > /etc/apt/sources.list.d/standard.list << 'EOF' deb http://deb.debian.org/debian stable main contrib non-free deb-src http://deb.debian.org/debian stable main contrib non-free EOF # Update package lists apt update -y fi # Install essential build dependencies echo "Installing essential build dependencies..." apt install -y \ libapt-pkg-dev \ libssl-dev \ libdbus-1-dev \ libglib2.0-dev \ libzstd-dev \ pkg-config \ curl \ git \ devscripts \ debhelper \ dh-cargo \ cargo \ rustc \ libcurl4-gnutls-dev \ libsystemd-dev \ libmount-dev \ libselinux1-dev \ libsepol-dev \ libarchive-dev \ libgpgme-dev \ libavahi-client-dev \ libavahi-common-dev \ libffi-dev \ libpcre2-dev \ libxml2-dev \ zlib1g-dev \ liblz4-dev \ liblzma-dev \ nettle-dev \ libgmp-dev \ libicu-dev \ libpython3-dev \ python3-dev \ python3-setuptools \ python3-wheel \ python3-pip echo "✅ All build dependencies installed successfully" - name: Checkout repository manually run: | # Clone the repository manually instead of using actions/checkout git clone https://git.raines.xyz/robojerk/apt-ostree.git /tmp/apt-ostree cp -r /tmp/apt-ostree/* . cp -r /tmp/apt-ostree/.* . 2>/dev/null || true - name: Install curl and jq for API testing run: | apt-get update -y apt-get install -y curl jq - name: Debug - Check ACCESS_TOKEN (safe) run: | echo "=== Debugging ACCESS_TOKEN ===" echo "Token exists: ${{ secrets.ACCESS_TOKEN != '' }}" echo "Token length: ${#ACCESS_TOKEN}" echo "Token first 4 chars: $(echo "$ACCESS_TOKEN" | cut -c1-4)..." echo "Token last 4 chars: ...$(echo "$ACCESS_TOKEN" | rev | cut -c1-4 | rev)" echo "Environment variable name: ACCESS_TOKEN" echo "Available secrets:" env | grep -i token || echo "No token env vars found" env: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} - name: Test API endpoints run: | echo "=== Testing Forgejo API endpoints with ACCESS_TOKEN ===" # Test 1: Check Forgejo version and capabilities echo "Testing Forgejo version..." curl -s -H "Authorization: token $ACCESS_TOKEN" \ "https://git.raines.xyz/api/v1/version" | jq '.' || echo "Version endpoint failed" # Test 2: Check repository info echo "=== Testing repository info ===" echo "Testing repository info..." curl -s -H "Authorization: token $ACCESS_TOKEN" \ "https://git.raines.xyz/api/v1/repos/robojerk/apt-ostree" | jq '.' || echo "Repository endpoint failed" # Test 3: Check package registry endpoints echo "=== Testing package registry endpoints ===" echo "Testing package registry availability..." curl -s -H "Authorization: token $ACCESS_TOKEN" \ "https://git.raines.xyz/api/v1/user/packages" | jq '.' || echo "User packages endpoint failed" # Test 4: Check repository packages echo "=== Testing repository packages ===" echo "Testing repository packages..." curl -s -H "Authorization: token $ACCESS_TOKEN" \ "https://git.raines.xyz/api/v1/repos/robojerk/apt-ostree/packages" | jq '.' || echo "Repository packages endpoint failed" # Test 5: Check Debian package registry echo "=== Testing Debian package registry ===" echo "Testing Debian package registry..." curl -s -H "Authorization: token $ACCESS_TOKEN" \ "https://git.raines.xyz/api/packages/robojerk/debian" | jq '.' || echo "Debian packages endpoint failed" - name: Install additional dependencies run: | # Update package lists apt update -y # Install additional dependencies that might be needed apt install -y \ libapt-pkg-dev \ libssl-dev \ libdbus-1-dev \ libglib2.0-dev \ libzstd-dev \ pkg-config \ curl \ git \ devscripts \ debhelper \ dh-cargo \ cargo \ rustc \ libcurl4-gnutls-dev \ libsystemd-dev \ libmount-dev \ libselinux1-dev \ libsepol-dev \ libarchive-dev \ libgpgme-dev \ libavahi-client-dev \ libavahi-common-dev \ libffi-dev \ libpcre2-dev \ libxml2-dev \ zlib1g-dev \ liblz4-dev \ liblzma-dev \ nettle-dev \ libgmp-dev \ libicu-dev \ libpython3-dev \ python3-dev \ python3-setuptools \ python3-wheel \ python3-pip - name: Debug - List files before building run: | echo "Current directory: $(pwd)" echo "Files in current directory:" ls -la echo "Files in src/ (if it exists):" ls -la src/ 2>/dev/null || echo "src/ directory does not exist" echo "Files in debian/ (if it exists):" ls -la debian/ 2>/dev/null || echo "debian/ directory does not exist" - name: Test cargo build shell: bash run: | # Source Rust environment for the build . ~/.cargo/env cargo build --release echo "✅ Cargo build successful" - name: Test cargo test shell: bash run: | # Source Rust environment for the tests . ~/.cargo/env cargo test echo "✅ Cargo tests successful" - name: Build apt-ostree package shell: bash run: | # Source Rust environment and ensure default toolchain is set . ~/.cargo/env rustup default stable # Set environment variables for the entire build process export PATH="$HOME/.cargo/bin:$PATH" export CARGO_HOME="$HOME/.cargo" export RUSTUP_HOME="$HOME/.rustup" echo "Building apt-ostree package..." # Check if build script exists and make it executable if [ -f "./build-debian-trixie.sh" ]; then echo "✅ Build script found, making it executable..." chmod +x ./build-debian-trixie.sh # Build the package ./build-debian-trixie.sh echo "✅ Package build successful" else echo "⚠️ Build script not found, attempting manual build..." # Try manual build process echo "Installing build dependencies..." apt-get update apt-get install -y \ build-essential \ devscripts \ debhelper \ dh-cargo \ cargo \ rustc \ pkg-config \ libssl-dev \ libdbus-1-dev \ libglib2.0-dev \ libapt-pkg-dev \ libzstd-dev \ libcurl4-gnutls-dev \ libsystemd-dev \ libmount-dev \ libselinux1-dev \ libsepol-dev \ libarchive-dev \ libgpgme-dev \ libavahi-client-dev \ libavahi-common-dev \ libffi-dev \ libpcre2-dev \ libxml2-dev \ zlib1g-dev \ liblz4-dev \ liblzma-dev \ nettle-dev \ libgmp-dev \ libicu-dev \ libpython3-dev \ python3-dev \ python3-setuptools \ python3-wheel \ python3-pip echo "Building package manually..." dpkg-buildpackage -us -uc -b if [ $? -eq 0 ]; then echo "✅ Manual package build successful" else echo "❌ Manual package build failed" exit 1 fi fi - name: List built packages run: | echo "Built packages:" ls -la ../*.deb ../*.ddeb ../*.changes ../*.buildinfo 2>/dev/null || echo "No packages found" - name: Test package installation run: | echo "Testing package installation..." # Find the main package MAIN_PKG=$(ls ../apt-ostree_*.deb | head -1) if [ -n "$MAIN_PKG" ]; then echo "Installing package: $MAIN_PKG" # Install the package dpkg -i "$MAIN_PKG" # Check if apt-ostree is available if command -v apt-ostree >/dev/null 2>&1; then echo "✅ apt-ostree installed successfully" apt-ostree --version || echo "Version check failed" else echo "❌ apt-ostree not found in PATH" echo "Checking installation location:" find /usr -name "apt-ostree" 2>/dev/null || echo "Not found in /usr" fi else echo "❌ No main package found to test" fi - name: Publish to Forgejo Package Registry if: success() run: | echo "Publishing packages to Forgejo Package Registry..." # Find all .deb packages DEB_PACKAGES=$(ls ../*.deb 2>/dev/null || echo "") if [ -n "$DEB_PACKAGES" ]; then for pkg in $DEB_PACKAGES; do echo "Publishing package: $pkg" # Extract package name and version PKG_NAME=$(dpkg-deb -f "$pkg" Package) PKG_VERSION=$(dpkg-deb -f "$pkg" Version) PKG_ARCH=$(dpkg-deb -f "$pkg" Architecture) echo "Package: $PKG_NAME" echo "Version: $PKG_VERSION" echo "Architecture: $PKG_ARCH" # Create package metadata cat > package.json << 'EOF' { "name": "$PKG_NAME", "version": "$PKG_VERSION", "architecture": "$PKG_ARCH", "description": "APT-OSTree package for Debian-based OSTree systems", "homepage": "https://git.raines.xyz/robojerk/apt-ostree", "repository": "https://git.raines.xyz/robojerk/apt-ostree.git", "license": "MIT", "keywords": ["ostree", "apt", "debian", "ubuntu", "immutable", "atomic"], "author": "Robojerk ", "maintainer": "Robojerk " } EOF # Upload package to Forgejo Package Registry # Note: This is a placeholder - actual implementation depends on Forgejo API echo "Package metadata created for $PKG_NAME" echo "Would upload to Forgejo Package Registry here" done else echo "❌ No .deb packages found to publish" fi - name: Create build summary run: | echo "Creating build summary..." # Create a summary markdown file cat > BUILD_SUMMARY.md << 'EOF' # APT-OSTree Build Summary ## Build Information - **Build Date**: $(date '+%Y-%m-%d %H:%M:%S UTC') - **Build ID**: ${{ forge.run_number }} - **Commit**: ${{ forge.sha }} - **Branch**: ${{ forge.ref_name }} ## Build Status - **Status**: ✅ SUCCESS - **Container**: debian:latest - **Rust Version**: $(rustc --version) - **Cargo Version**: $(cargo --version) ## Built Packages EOF # Add package information if ls ../*.deb >/dev/null 2>&1; then echo "" >> BUILD_SUMMARY.md echo "### Debian Packages" >> BUILD_SUMMARY.md for pkg in ../*.deb; do PKG_NAME=$(dpkg-deb -f "$pkg" Package 2>/dev/null || echo "Unknown") PKG_VERSION=$(dpkg-deb -f "$pkg" Version 2>/dev/null || echo "Unknown") PKG_ARCH=$(dpkg-deb -f "$pkg" Architecture 2>/dev/null || echo "Unknown") PKG_SIZE=$(du -h "$pkg" | cut -f1) echo "- **$PKG_NAME** ($PKG_VERSION) [$PKG_ARCH] - $PKG_SIZE" >> BUILD_SUMMARY.md done fi # Add dependency information echo "" >> BUILD_SUMMARY.md echo "### Dependencies" >> BUILD_SUMMARY.md echo "- libapt-pkg-dev ✅" >> BUILD_SUMMARY.md echo "- libssl-dev ✅" >> BUILD_SUMMARY.md echo "- libdbus-1-dev ✅" >> BUILD_SUMMARY.md echo "- libglib2.0-dev ✅" >> BUILD_SUMMARY.md echo "- All build dependencies satisfied ✅" >> BUILD_SUMMARY.md echo "Build summary created: BUILD_SUMMARY.md" echo "Build completed successfully! 🎉"