添加 .gitea/workflows/update-packages.yaml
All checks were successful
Build Arch Packages and Update Repo / build (push) Successful in 3m38s
All checks were successful
Build Arch Packages and Update Repo / build (push) Successful in 3m38s
This commit is contained in:
65
.gitea/workflows/update-packages.yaml
Normal file
65
.gitea/workflows/update-packages.yaml
Normal file
@@ -0,0 +1,65 @@
|
||||
name: Build Arch Packages and Update Repo
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # 当有代码推送到 main 分支时触发此工作流
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: arch # 指定使用带有 "archlinux:host" 标签的 runner
|
||||
|
||||
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: 移除构建依赖
|
||||
# -i: 安装包(如果需要,但这里我们只是构建)
|
||||
# -c: 清理构建目录
|
||||
# --noconfirm: 自动确认
|
||||
makepkg -s --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
|
||||
Reference in New Issue
Block a user