name: Update Arch Repository on: push: paths: - 'x86_64/*.pkg.tar.zst' workflow_dispatch: jobs: update-db: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup tools run: sudo apt-get update && sudo apt-get install -y libarchive-tools gpg - name: Import GPG Key run: | # Ensure you have added GPG_PRIVATE_KEY to your GitHub Secrets! echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --batch - name: Update Repository Database run: | cd x86_64 # Remove old DB and sig files to ensure a clean rebuild rm -f hyprarch-repo.db* hyprarch-repo.files* mkdir -p db_temp for pkg in *.pkg.tar.zst; do # 1. Sign the package file gpg --detach-sign --batch --no-armor --local-user 236328A7F2C2001E "$pkg" # 2. Extract and sanitize metadata # We filter out comments (#) to avoid pacman sync errors pkgname=$(bsdtar -xOf "$pkg" .PKGINFO | grep "^pkgname =" | cut -d' ' -f3) pkgver=$(bsdtar -xOf "$pkg" .PKGINFO | grep "^pkgver =" | cut -d' ' -f3) mkdir -p "db_temp/$pkgname-$pkgver" # Create the 'desc' file with required Pacman formatting { echo "%NAME%" echo "$pkgname" echo "" echo "%VERSION%" echo "$pkgver" echo "" # Pull other fields from PKGINFO but skip comments and already added fields bsdtar -xOf "$pkg" .PKGINFO | grep -v "^#" | grep -v "^pkgname" | grep -v "^pkgver" echo "" echo "%FILENAME%" echo "$pkg" echo "" echo "%CSIZE%" echo "$(stat -c%s "$pkg")" echo "" echo "%PGPSIG%" gpg --detach-sign --stdout --no-armor --local-user 236328A7F2C2001E "$pkg" | base64 | tr -d '\n' echo "" } > "db_temp/$pkgname-$pkgver/desc" done # 3. Pack the database cd db_temp tar -c * | gzip -9 > ../hyprarch-repo.db.tar.gz cd .. # 4. Sign the database itself gpg --detach-sign --batch --no-armor --local-user 236328A7F2C2001E hyprarch-repo.db.tar.gz # 5. Create final symlink-replacements for GitHub Pages cp hyprarch-repo.db.tar.gz hyprarch-repo.db cp hyprarch-repo.db.tar.gz.sig hyprarch-repo.db.sig cp hyprarch-repo.db.tar.gz hyprarch-repo.files rm -rf db_temp - name: Generate Subfolder Index run: | cd x86_64 echo "
" >> index.html
echo "../" >> index.html
for file in *; do
if [[ "$file" != "index.html" ]]; then
size=$(du -sh "$file" | cut -f1)
date=$(date -r "$file" '+%d-%b-%Y %H:%M')
printf "%s%-$(($(printf '%s' "$file" | wc -c) > 50 ? 1 : 50 - $(printf '%s' "$file" | wc -c)))s %s %8s\n" "$file" "$file" "" "$date" "$size" >> index.html
fi
done
echo "To use this repository, add the following to your /etc/pacman.conf:
[hyprarch-repo]
SigLevel = Required DatabaseOptional
Server = https://hyprarch-repo.stuple.net/$arch
Automated by GitHub Actions