name: Compile apt-layer on: push: branches: [ main, master ] paths: - 'src/apt-layer/**' - '.forgejo/workflows/compile-apt-layer.yml' pull_request: branches: [ main, master ] paths: - 'src/apt-layer/**' - '.forgejo/workflows/compile-apt-layer.yml' workflow_dispatch: # Allow manual triggering jobs: compile: runs-on: ubuntu-latest steps: - name: Checkout code run: | echo "Cloning repository from Forgejo..." git clone http://forgejo:3000/robojerk/particle-os-tools.git . git checkout ${{ github.sha }} echo "Repository checked out successfully" - name: Set up environment run: | echo "Setting up compilation environment..." sudo apt-get update sudo apt-get install -y jq dos2unix bash - name: Make compile scripts executable run: | chmod +x src/apt-layer/compile.sh chmod +x src/apt-layer/compile-installer.sh - name: Compile apt-layer run: | echo "Compiling apt-layer..." cd src/apt-layer ./compile.sh -o ../../apt-layer.sh - name: Compile installer run: | echo "Compiling installer with latest paths.json..." cd src/apt-layer ./compile-installer.sh -o ../../install-apt-layer.sh - name: Verify compilation run: | echo "Verifying compiled scripts..." # Check apt-layer.sh if [[ ! -f apt-layer.sh ]]; then echo "❌ apt-layer compilation failed - apt-layer.sh not found" exit 1 fi if [[ ! -x apt-layer.sh ]]; then echo "❌ apt-layer script is not executable" exit 1 fi # Test apt-layer.sh syntax if bash -n apt-layer.sh; then echo "✅ apt-layer.sh syntax validation passed" else echo "❌ apt-layer.sh syntax validation failed" exit 1 fi # Check apt-layer.sh file size file_size=$(du -h apt-layer.sh | cut -f1) echo "📦 apt-layer.sh size: $file_size" # Count apt-layer.sh lines line_count=$(wc -l < apt-layer.sh) echo "📄 apt-layer.sh lines: $line_count" # Check install-apt-layer.sh if [[ ! -f install-apt-layer.sh ]]; then echo "❌ Installer compilation failed - install-apt-layer.sh not found" exit 1 fi if [[ ! -x install-apt-layer.sh ]]; then echo "❌ Installer script is not executable" exit 1 fi # Test install-apt-layer.sh syntax if bash -n install-apt-layer.sh; then echo "✅ install-apt-layer.sh syntax validation passed" else echo "❌ install-apt-layer.sh syntax validation failed" exit 1 fi # Check install-apt-layer.sh file size installer_size=$(du -h install-apt-layer.sh | cut -f1) echo "📦 install-apt-layer.sh size: $installer_size" # Count install-apt-layer.sh lines installer_lines=$(wc -l < install-apt-layer.sh) echo "📄 install-apt-layer.sh lines: $installer_lines" - name: Test basic functionality run: | echo "Testing basic functionality..." # Test apt-layer.sh help command if ./apt-layer.sh --help > /dev/null 2>&1; then echo "✅ apt-layer.sh help command works" else echo "❌ apt-layer.sh help command failed" exit 1 fi # Test apt-layer.sh version info if ./apt-layer.sh --version > /dev/null 2>&1; then echo "✅ apt-layer.sh version command works" else echo "⚠️ apt-layer.sh version command not available (this is optional)" fi # Test install-apt-layer.sh help command if ./install-apt-layer.sh --help > /dev/null 2>&1; then echo "✅ install-apt-layer.sh help command works" else echo "❌ install-apt-layer.sh help command failed" exit 1 fi - name: Create compilation report run: | echo "Creating compilation report..." { echo "# apt-layer Compilation Report" echo "" echo "**Compilation Date:** $(date)" echo "**Commit:** ${{ github.sha }}" echo "**Branch:** ${{ github.ref_name }}" echo "" echo "## File Information" echo "" echo "### apt-layer.sh" echo "- **File:** apt-layer.sh" echo "- **Size:** $(du -h apt-layer.sh | cut -f1)" echo "- **Lines:** $(wc -l < apt-layer.sh)" echo "- **Executable:** $(test -x apt-layer.sh && echo "Yes" || echo "No")" echo "" echo "### install-apt-layer.sh" echo "- **File:** install-apt-layer.sh" echo "- **Size:** $(du -h install-apt-layer.sh | cut -f1)" echo "- **Lines:** $(wc -l < install-apt-layer.sh)" echo "- **Executable:** $(test -x install-apt-layer.sh && echo "Yes" || echo "No")" echo "" echo "## Validation Results" echo "- **apt-layer.sh Syntax Check:** $(bash -n apt-layer.sh && echo "✅ Passed" || echo "❌ Failed")" echo "- **apt-layer.sh Help Command:** $(./apt-layer.sh --help > /dev/null 2>&1 && echo "✅ Works" || echo "❌ Failed")" echo "- **install-apt-layer.sh Syntax Check:** $(bash -n install-apt-layer.sh && echo "✅ Passed" || echo "❌ Failed")" echo "- **install-apt-layer.sh Help Command:** $(./install-apt-layer.sh --help > /dev/null 2>&1 && echo "✅ Works" || echo "❌ Failed")" echo "" echo "## Included Components" echo "" echo "### apt-layer.sh" echo "- apt-layer configuration integration" echo "- Transactional operations with automatic rollback" echo "- Traditional chroot-based layer creation" echo "- Container-based layer creation (Apx-style)" echo "- OCI export/import integration" echo "- Live overlay system (rpm-ostree style)" echo "- Bootloader integration (UEFI/GRUB/systemd-boot)" echo "- Atomic deployment system with rollback" echo "- rpm-ostree compatibility layer" echo "- ComposeFS backend integration" echo "- Dependency validation and error handling" echo "- Comprehensive JSON configuration system" echo "- Direct dpkg installation (Performance optimization)" echo "" echo "### install-apt-layer.sh" echo "- Latest paths.json configuration embedded" echo "- All installation and uninstallation functionality" echo "- Dependency checking and installation" echo "- System initialization" echo "- Proper error handling and validation" echo "" echo "## Ready for Distribution" echo "Both compiled scripts are self-contained and ready for use!" } > COMPILATION_REPORT.md - name: Create artifacts directory run: | mkdir -p artifacts cp apt-layer.sh artifacts/ cp install-apt-layer.sh artifacts/ cp COMPILATION_REPORT.md artifacts/ - name: Display compilation results run: | echo "==========================================" echo "📦 COMPILATION COMPLETED SUCCESSFULLY" echo "==========================================" echo "" echo "Generated files:" echo "✅ apt-layer.sh ($(du -h apt-layer.sh | cut -f1))" echo "✅ install-apt-layer.sh ($(du -h install-apt-layer.sh | cut -f1))" echo "✅ COMPILATION_REPORT.md" echo "" echo "Files are available in the artifacts/ directory" echo "==========================================" - name: Commit compiled scripts (if on main/master) if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' run: | echo "Committing compiled scripts to repository..." git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add apt-layer.sh install-apt-layer.sh git diff --staged --quiet || git commit -m "Auto-compile apt-layer and installer from commit ${{ github.sha }}" git push