From cc11a162ce33f7e58957724115a016bd5dc87eb0 Mon Sep 17 00:00:00 2001 From: madonuko Date: Sat, 7 Feb 2026 16:04:31 +0800 Subject: [PATCH] feat(ci): make rabo PR bumps --- .github/workflows/update-branch.yml | 7 ++++--- .github/workflows/update-nightly.yml | 17 ++++------------ .github/workflows/update-weekly.yml | 17 ++++------------ .github/workflows/update.yml | 19 +++++------------- andax/ci/update_commit_message.rhai | 13 ------------ andax/ci/update_pr.rhai | 30 ++++++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 56 deletions(-) delete mode 100644 andax/ci/update_commit_message.rhai create mode 100644 andax/ci/update_pr.rhai diff --git a/.github/workflows/update-branch.yml b/.github/workflows/update-branch.yml index 4e41a61276..ee7dd671b3 100644 --- a/.github/workflows/update-branch.yml +++ b/.github/workflows/update-branch.yml @@ -1,6 +1,7 @@ name: Update per branch permissions: contents: write + pull-requests: write on: schedule: - cron: "*/30 * * * *" @@ -50,7 +51,7 @@ jobs: git config user.email "raboneko@fyralabs.com" git config gpg.format "ssh" git config user.signingkey "${{ runner.temp }}/signing_key" - msg="bump(branch): $(anda run andax/ci/update_commit_message.rhai)" - git commit -S -a -m "$msg" - git push -u origin --all + anda run andax/ci/update_pr.rhai -l scope=branch fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-nightly.yml b/.github/workflows/update-nightly.yml index 52a244b1b2..8b4c3ee7ed 100644 --- a/.github/workflows/update-nightly.yml +++ b/.github/workflows/update-nightly.yml @@ -1,6 +1,7 @@ name: Nightly Update permissions: contents: write + pull-requests: write on: schedule: - cron: "0 0 * * *" @@ -39,17 +40,7 @@ jobs: git config user.email "raboneko@fyralabs.com" git config gpg.format "ssh" git config user.signingkey "${{ runner.temp }}/signing_key" - msg="bump(nightly): $(anda run andax/ci/update_commit_message.rhai)" - git commit -S -a -m "$msg" - git format-patch HEAD^ - copy_over () { - git checkout $1 - git apply *.patch || true - git add anda - git commit -S -a -m "$msg" - } - copy_over f43 || true - copy_over f42 || true - copy_over el10 || true - git push -u origin --all + anda run andax/ci/update_pr.rhai -l scope=nightly fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-weekly.yml b/.github/workflows/update-weekly.yml index ddd62a4ea4..c2f67cdbbe 100644 --- a/.github/workflows/update-weekly.yml +++ b/.github/workflows/update-weekly.yml @@ -1,6 +1,7 @@ name: Weekly Update permissions: contents: write + pull-requests: write on: schedule: - cron: "0 0 * * *" @@ -39,17 +40,7 @@ jobs: git config user.email "raboneko@fyralabs.com" git config gpg.format "ssh" git config user.signingkey "${{ runner.temp }}/signing_key" - msg="bump(weekly): $(anda run andax/ci/update_commit_message.rhai)" - git commit -S -a -m "$msg" - git format-patch HEAD^ - copy_over () { - git checkout $1 - git apply *.patch || true - git add anda - git commit -S -a -m "$msg" - } - copy_over f43 || true - copy_over f42 || true - copy_over el10 || true - git push -u origin --all + anda run andax/ci/update_pr.rhai -l scope=weekly fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 0ef305b8d7..4d1a7515c9 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -1,6 +1,7 @@ name: Update permissions: contents: write + pull-requests: write on: schedule: - cron: "*/10 * * * *" @@ -27,7 +28,7 @@ jobs: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Run Update - run: anda update --excludes nightly=1 --excludes weekly=1 --excludes updbranch=1 + run: anda update -e nightly=1 -e updbranch=1 -e weekly=0 -e weekly=1 -e weekly=2 -e weekly=3 -e weekly=4 -e weekly=5 -e weekly=6 env: GITHUB_TOKEN: ${{ secrets.AUTOUPDATE_GH_TOKEN }} RUST_BACKTRACE: full @@ -39,17 +40,7 @@ jobs: git config user.email "raboneko@fyralabs.com" git config gpg.format "ssh" git config user.signingkey "${{ runner.temp }}/signing_key" - msg="bump: $(anda run andax/ci/update_commit_message.rhai)" - git commit -S -a -m "$msg" - git format-patch HEAD^ - copy_over () { - git checkout $1 - git apply *.patch || true - git add anda - git commit -S -a -m "$msg" - } - copy_over f43 || true - copy_over f42 || true - copy_over el10 || true - git push -u origin --all + anda run andax/ci/update_pr.rhai -l scope=auto fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/andax/ci/update_commit_message.rhai b/andax/ci/update_commit_message.rhai deleted file mode 100644 index 889800652c..0000000000 --- a/andax/ci/update_commit_message.rhai +++ /dev/null @@ -1,13 +0,0 @@ -import "anda::cfg" as cfg; - -let cmd = `git status | sed -nE '/^\tmodified:/{s@^\tmodified:\s+@@;s@[^/]+$@@;p}' | sort -u`; -let filelist = sh(cmd, #{ "stdout": "piped" }).ctx.stdout.split('\n'); - -let modified_list = ""; -for file in filelist { - if file.is_empty() { continue; } - let spec = cfg::load_file(`${file}/anda.hcl`).project.pkg.rpm.spec; - spec.pop(5); // remove `.spec` suffix - modified_list += `${spec} `; -} -print(modified_list[..modified_list.len()-1]); diff --git a/andax/ci/update_pr.rhai b/andax/ci/update_pr.rhai new file mode 100644 index 0000000000..bdbe3b0206 --- /dev/null +++ b/andax/ci/update_pr.rhai @@ -0,0 +1,30 @@ +import "anda::cfg" as cfg; + +fn pr(branch, dir, spec) { + sh(`git checkout ${branch}`, #{}); + if sh(`git stash apply`, #{}).ctx.rc != 0 { + sh(`git reset HEAD ${dir}`, #{}); + return; + } + if sh(`git commit -S -m "bump(${labels.scope}): ${spec}" ${dir}`, #{}).ctx.rc != 0 { + sh(`git reset HEAD ${dir}`, #{}); + return; + } + sh(`gh pr create --title '[${branch}] bump(${labels.scope}): ${spec}' --body 'Automatic bump from CI'`, #{}); + sh(`git reset --hard HEAD^`, #{}); +} + +let cmd = `git status | sed -nE '/^\tmodified:/{s@^\tmodified:\s+@@;s@[^/]+$@@;p}' | sort -u`; +let filelist = sh(cmd, #{ "stdout": "piped" }).ctx.stdout.split('\n'); + +for dir in filelist { + if dir.is_empty() { continue; } + let spec = cfg::load_file(`${dir}/anda.hcl`).project.pkg.rpm.spec; + spec.pop(5); // remove `.spec` suffix + sh(`git stash push -m "bump(${labels.scope}): ${spec}" -- ${dir}`, #{}); + pr("frawhide", dir, spec); + pr("f43", dir, spec); + pr("f42", dir, spec); + pr("el10", dir, spec); + sh(`git stash drop`, #{}); +}