From f18e57bfd173f0eb7b086050547ef6f8e6ddc0cd Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Sat, 24 Oct 2026 07:30:57 +0900 Subject: [PATCH] ci(release): the index bump is proposed by the index's own updater Since openxlings/xim-pkgindex#1027 one updater edits every recipe (`xpkgindex-update.yml`), and `.github/scripts/version-check.py`, which bump_index.sh ran inside a clone, is gone. The 2026.10.24.1 release's publish-ecosystem failed on the missing file; its bump was dispatched by hand (xim-pkgindex#1047). bump_index.sh now dispatches the updater for xim: and waits for `auto/bump-xim--`, failing when it does not appear, so the step stays blocking. Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com> --- .github/tools/bump_index.sh | 103 +++++++++++++--------------------- .github/workflows/release.yml | 2 + 2 files changed, 40 insertions(+), 65 deletions(-) diff --git a/.github/tools/bump_index.sh b/.github/tools/bump_index.sh index 36a151641..77d2bef56 100755 --- a/.github/tools/bump_index.sh +++ b/.github/tools/bump_index.sh @@ -1,82 +1,55 @@ #!/usr/bin/env bash -# Open a PR against openxlings/xim-pkgindex that bumps to . +# Ask openxlings/xim-pkgindex to propose , and wait for the PR. # -# The actual lua edit is delegated to the index repo's OWN -# `.github/scripts/version-check.py --apply --only `, so this script -# stays agnostic to each package's contract: -# - res_versioned packages (e.g. xlings): appends `[""] = "XLINGS_RES"`. -# - url_template packages (e.g. mcpp): downloads the artifact, computes -# sha256, appends `[""] = { url, sha256 }`. -# and always bumps `["latest"].ref`. Existing version entries are untouched. +# The index edits its own recipes. Since openxlings/xim-pkgindex#1027 one +# updater does it for every package (`xpkgindex-update.yml`, pinned +# openxlings/xpkgindex-update): it discovers the release from the recipe's +# `extensions.autoupdate.source` (xlings-res/ releases), requires the +# GLOBAL and CN resources, computes each sha256 and opens +# `auto/bump-xim--`. The script that used to do this here, +# `.github/scripts/version-check.py`, was removed from the index by that +# change; 2026.10.24.1 is the release that found out (publish-ecosystem +# failed on the missing file). Asking the index's own updater keeps one writer +# of the recipe. # -# This opens a PR only — a maintainer reviews and merges it (index git source -# is intentionally NOT on the release critical path; availability is already -# guaranteed by the xlings-res binary mirror + index artifact). On merge, the -# index repo republishes its artifact + gitee-sync picks it up. +# This opens a PR only -- a maintainer reviews and merges it. It runs after +# the binaries are mirrored, because the updater requires both hosts. # -# Usage: tools/bump_index.sh # e.g. mcpp 0.0.82 +# Usage: bump_index.sh # e.g. mcpp 2026.10.24.1 # Auth: -# PKGINDEX_TOKEN (required) — write to openxlings/xim-pkgindex (clone/push/PR) -# GITHUB_TOKEN (optional) — GitHub API rate headroom + artifact download -# for url_template packages (version-check.py) +# PKGINDEX_TOKEN (required) -- may dispatch workflows of openxlings/xim-pkgindex set -euo pipefail PROJ="${1:?usage: bump_index.sh }" VER="${2:?usage: bump_index.sh }" INDEX_REPO="${INDEX_REPO:-openxlings/xim-pkgindex}" -BRANCH="bump/${PROJ}-${VER}" -TOKEN="${PKGINDEX_TOKEN:?PKGINDEX_TOKEN required (write to $INDEX_REPO)}" +BRANCH="auto/bump-xim-${PROJ}-${VER}" +WAIT_S="${BUMP_WAIT_S:-1200}" +export GH_TOKEN="${PKGINDEX_TOKEN:?PKGINDEX_TOKEN required (dispatch on $INDEX_REPO)}" info() { echo "[bump] $*"; } -WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT -info "cloning $INDEX_REPO" -git clone -q --depth 20 "https://x-access-token:${TOKEN}@github.com/${INDEX_REPO}.git" "$WORK/idx" -cd "$WORK/idx" -git config user.email "ci@xlings.dev" -git config user.name "xlings-ci" -git checkout -q -B "$BRANCH" +pr_url() { gh pr view "$BRANCH" -R "$INDEX_REPO" --json url --jq .url 2>/dev/null || true; } -info "version-check.py --apply --only $PROJ" -# --workspace: version-check.py defaults its repo root to GITHUB_WORKSPACE, -# which inside the RELEASE repo's runner is the release repo — not this -# freshly-cloned index. Point it at the clone explicitly ("error: …/pkgs not -# found" was this default kicking in; observed on the 0.0.83 release). -python3 .github/scripts/version-check.py --workspace . --apply --only "$PROJ" > "$WORK/report.json" || { - echo "[bump] version-check failed:" >&2; cat "$WORK/report.json" >&2 2>/dev/null || true; exit 1; -} - -if git diff --quiet; then - info "no change — index already tracks the latest $PROJ; nothing to PR" +if url="$(pr_url)" && [[ -n "$url" ]]; then + info "PR already open: $url" exit 0 fi -# Sanity: the resulting latest.ref should equal the released version. A -# mismatch usually means GitHub's releases/latest hasn't caught up yet (API -# lag) or a newer release exists — warn but still open the PR. -GOT="$(grep -oE 'ref = "[^"]+"' pkgs/*/"${PROJ}".lua 2>/dev/null | head -1 | sed -E 's/.*"([^"]+)".*/\1/' || true)" -if [[ -n "$GOT" && "$GOT" != "$VER" ]]; then - echo "[bump] WARN: bumped latest.ref to '$GOT' but release version is '$VER' (upstream 'latest' differs?)" -fi - -git add -A -git commit -qm "bump(${PROJ}): track ${VER} as latest - -Auto-generated by the ${PROJ} release pipeline (bump_index.sh). -Applied via version-check.py --apply --only ${PROJ}." - -info "pushing $BRANCH (force — bot branch)" -git push -q -f "https://x-access-token:${TOKEN}@github.com/${INDEX_REPO}.git" "$BRANCH" - -# Open PR — idempotent: a force-push updates an already-open PR in place. -export GH_TOKEN="$TOKEN" -if gh pr view "$BRANCH" -R "$INDEX_REPO" >/dev/null 2>&1; then - info "PR already open for $BRANCH (updated by force-push)" -else - gh pr create -R "$INDEX_REPO" --base main --head "$BRANCH" \ - --title "bump(${PROJ}): track ${VER} as latest" \ - --body "Automated by the ${PROJ} release pipeline. Bumps \`pkgs/*/${PROJ}.lua\` \`latest.ref\` to \`${VER}\` and appends the new version entry (via \`version-check.py --apply --only ${PROJ}\`). - -Merge to publish into the official index — the index repo then republishes its artifact and gitee-sync mirrors the change. Binaries are already live on \`xlings-res/${PROJ}\` (GitHub + GitCode)." - info "PR opened" -fi +info "dispatching xpkgindex-update.yml for xim:$PROJ" +gh workflow run xpkgindex-update.yml -R "$INDEX_REPO" --ref main -f "package=xim:$PROJ" + +deadline=$(( $(date +%s) + WAIT_S )) +while (( $(date +%s) < deadline )); do + sleep 30 + if url="$(pr_url)" && [[ -n "$url" ]]; then + info "PR opened: $url" + exit 0 + fi +done + +# BLOCKING: without the PR the index never learns the release exists. The +# updater's run says why (a resource missing on one host, a policy refusal). +echo "[bump] no $BRANCH after ${WAIT_S}s; see" \ + "https://github.com/$INDEX_REPO/actions/workflows/xpkgindex-update.yml" >&2 +exit 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59d0ba1e5..f953a03a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -969,6 +969,8 @@ jobs: chmod +x .github/tools/bump_index.sh # A4: BLOCKING — a missing bump PR means the index never learns the # release exists and every post-release install of the new version 404s. + # The index's own updater writes the PR (bump_index.sh says why); + # it needs the GitCode mirror above to be complete. bash .github/tools/bump_index.sh mcpp "${{ steps.version.outputs.version }}" # Post-release verification (ci-fresh-install) is triggered via its