Files
custompkgs/.gitea/workflows/update-packages.yaml
zj e0f30d12f0
All checks were successful
Build Arch Packages and Update Repo / build (push) Successful in 3m8s
更新 .gitea/workflows/update-packages.yaml
2025-11-28 01:37:17 +08:00

65 lines
2.2 KiB
YAML

name: Build Arch Packages and Update Repo
on:
push:
branches:
- main
jobs:
build:
runs-on: arch
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整的 Git 历史,以便后续提交和推送
- name: Set up Git user
run: |
git config user.name "zj"
git config user.email "1052308257@qq.com" # 使用一个专用的邮箱地址
- name: Build and update packages
run: |
# 遍历所有包含 PKGBUILD 的子目录并构建它们
for pkgdir in $(find . -maxdepth 2 -type f -name "PKGBUILD" -print0 | xargs -0 -n1 dirname); do
echo "--- Building package in $pkgdir ---"
cd "$pkgdir"
# makepkg -sric:
# -s: 同步依赖
# -r: 移除构建依赖
# -c: 清理构建目录
# --noconfirm: 自动确认
makepkg -sc --noconfirm || { echo "::error::Failed to build package in $pkgdir"; exit 1; }
# 将生成的包移动到 x86_64 目录
mv *.pkg.tar.zst ../x86_64/ || true
cd - # 返回上级目录
done
# 确保 x86_64 目录存在
mkdir -p x86_64
# 更新仓库数据库
echo "--- Updating repository database ---"
cd x86_64
# 运行你的 update-database.sh 脚本
# 假设 update-database.sh 内部调用了 repo-add custom.db.tar.gz *.pkg.tar.zst
chmod +x ../update-database.sh
../update-database.sh || { echo "::error::Failed to update repository database"; exit 1; }
cd ..
- name: Commit and push changes
run: |
# 添加所有新的 .pkg.tar.zst 包和更新后的数据库文件
git add x86_64/*.pkg.tar.zst x86_64/*.db x86_64/*.files
# 检查是否有实际的更改需要提交
if ! git diff --cached --exit-code; then
git commit -m "chore(repo): Update packages and repo database [skip ci]"
# [skip ci] 避免本次提交再次触发工作流,造成无限循环
git push
else
echo "No changes to commit."
fi