Files
Christof Seyfferth a100ae4ac0
Some checks failed
Build Arch Packages / detect-changes (push) Successful in 5s
Build Arch Packages / build-packages (push) Failing after 34s
.gitea/workflows/build-package.yml aktualisiert
2025-08-29 15:45:32 +02:00

214 lines
6.2 KiB
YAML

name: Build Arch Packages
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.changes.outputs.packages }}
matrix: ${{ steps.changes.outputs.matrix }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Debug Repository Structure
run: |
echo "📁 Repository structure:"
find . -name "PKGBUILD" -type f | head -20
echo ""
ls -la
- name: Detect Changed Packages
id: changes
run: |
echo "🔍 Detecting packages..."
# Alle verfügbaren Pakete finden
all_packages=$(find . -name "PKGBUILD" -type f | xargs dirname | sed 's|^\./||' | sort)
echo "Found packages:"
echo "$all_packages"
if [ -z "$all_packages" ]; then
echo "❌ No PKGBUILD files found!"
echo "packages=[]" >> $GITHUB_OUTPUT
echo "matrix=[]" >> $GITHUB_OUTPUT
exit 0
fi
# Bei Push: nur geänderte Pakete (vereinfacht)
if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
changed_files=$(git diff --name-only ${{ github.event.before }}..${{ github.sha }})
echo "Changed files: $changed_files"
packages_to_build=""
for pkg in $all_packages; do
if echo "$changed_files" | grep -q "^$pkg/"; then
packages_to_build="$packages_to_build$pkg"$'\n'
fi
done
# Falls keine Änderungen in Paketen, trotzdem alle bauen (für ersten Test)
if [ -z "$packages_to_build" ]; then
packages_to_build="$all_packages"
fi
else
packages_to_build="$all_packages"
fi
# Leere Zeilen entfernen
packages_to_build=$(echo "$packages_to_build" | grep -v '^$' | sort | uniq)
echo "Packages to build:"
echo "$packages_to_build"
# JSON Arrays erstellen
if [ -n "$packages_to_build" ]; then
# Korrekte JSON-Erstellung
packages_json="["
matrix_json="["
first=true
while IFS= read -r pkg; do
if [ -n "$pkg" ]; then
if [ "$first" = true ]; then
first=false
else
packages_json="$packages_json,"
matrix_json="$matrix_json,"
fi
packages_json="$packages_json\"$pkg\""
matrix_json="$matrix_json{\"package\":\"$pkg\"}"
fi
done <<< "$packages_to_build"
packages_json="$packages_json]"
matrix_json="$matrix_json]"
else
packages_json="[]"
matrix_json="[]"
fi
echo "Final JSON:"
echo "packages=$packages_json"
echo "matrix=$matrix_json"
echo "packages=$packages_json" >> $GITHUB_OUTPUT
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
build-packages:
needs: detect-changes
if: needs.detect-changes.outputs.packages != '[]'
strategy:
matrix:
include: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
fail-fast: false
runs-on: ubuntu-latest
container:
image: archlinux:latest
steps:
- name: Setup Build Environment
run: |
echo "🔧 Setting up build environment..."
pacman -Syu --noconfirm
pacman -S --noconfirm base-devel git nodejs npm namcap pacman-contrib sudo
useradd -m -G wheel builder
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
- name: Checkout Repository
uses: actions/checkout@v4
- name: Debug Matrix Variables
run: |
echo "🐛 Debug Matrix Variables:"
echo "matrix.package: '${{ matrix.package }}'"
echo "Current directory: $(pwd)"
echo "Directory contents:"
ls -la
if [ -n "${{ matrix.package }}" ]; then
echo "Target package directory: ${{ matrix.package }}"
if [ -d "${{ matrix.package }}" ]; then
echo "✅ Directory exists"
ls -la "${{ matrix.package }}"
else
echo "❌ Directory does not exist"
fi
else
echo "❌ matrix.package is empty!"
exit 1
fi
- name: Package Information
run: |
package_dir="${{ matrix.package }}"
if [ -z "$package_dir" ]; then
echo "❌ Package directory is empty"
exit 1
fi
if [ ! -d "$package_dir" ]; then
echo "❌ Package directory '$package_dir' does not exist"
exit 1
fi
echo "📦 Building package: $package_dir"
cd "$package_dir"
if [ ! -f "PKGBUILD" ]; then
echo "❌ No PKGBUILD found in $package_dir"
exit 1
fi
# PKGBUILD info
source PKGBUILD
echo "Package name: $pkgname"
echo "Version: $pkgver-$pkgrel"
echo "Description: $pkgdesc"
# Set ownership
chown -R builder:builder /workspace/cseyfferth/repo
- name: Validate PKGBUILD
run: |
cd "${{ matrix.package }}"
echo "🔍 Validating PKGBUILD..."
sudo -u builder namcap PKGBUILD
- name: Build Package
run: |
cd "${{ matrix.package }}"
echo "🔨 Building package..."
sudo -u builder makepkg -s --noconfirm --needed
echo "✅ Built packages:"
ls -la *.pkg.tar.zst
- name: Test Package
run: |
cd "${{ matrix.package }}"
echo "🧪 Testing packages..."
for pkg in *.pkg.tar.zst; do
if [ -f "$pkg" ]; then
echo "Testing $pkg..."
sudo -u builder namcap "$pkg" || true
fi
done
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}-package
path: ${{ matrix.package }}/*.pkg.tar.zst
retention-days: 30