From 4fe9bcf413a6637c5a8cf8685db8efdcf99d0e2d Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Tue, 19 May 2026 11:26:13 +0200 Subject: [PATCH] fix(ci): skip unreleased stable branch as deployment target Mirror the is_version_released() check from build/build-index.php in the sphinxbuild deploy job. Instead of taking the highest-numbered stable branch from git refs, iterate descending and check for a v{N}.0.0 GitHub release tag. First branch with a real release wins. This prevents a pre-release branch (e.g. stable34 with RC1 only) from being deployed to server/stable/ on gh-pages. Signed-off-by: skjnldsv Signed-off-by: skjnldsv --- .github/workflows/sphinxbuild.yml | 34 +++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sphinxbuild.yml b/.github/workflows/sphinxbuild.yml index 1e5bb441867..79064abff2f 100644 --- a/.github/workflows/sphinxbuild.yml +++ b/.github/workflows/sphinxbuild.yml @@ -270,6 +270,8 @@ jobs: # ======================================================================== - name: Determine deployment targets (branch_name and version_name) id: branch + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Determine which branch we're building from current_branch=${GITHUB_REF#refs/heads/} @@ -277,13 +279,37 @@ jobs: current_branch=${GITHUB_BASE_REF} fi - # Find the highest numbered stable branch from the remote - # e.g., "stable30", "stable31", "stable32" → extract "32" - highest_stable=$(git ls-remote --heads origin | sed -n 's?.*refs/heads/stable\([0-9]\{2\}\)$?\1?p' | sort -n | tail -1) + # Find the highest numbered stable branch that has a v{N}.0.0 release. + # Mirrors the is_version_released() check in build/build-index.php: + # a branch whose first release doesn't exist yet (e.g. RC-only) is skipped. + highest_stable="" + for n in $(git ls-remote --heads origin | sed -n 's?.*refs/heads/stable\([0-9]\{2\}\)$?\1?p' | sort -n -r); do + # Nextcloud moved to nextcloud-releases/server starting with v32 + if [ "$n" -ge 32 ]; then + repo="nextcloud-releases/server" + else + repo="nextcloud/server" + fi + http_status=$(curl -s -o /dev/null -w "%{http_code}" \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + "https://api.github.com/repos/${repo}/releases/tags/v${n}.0.0") + if [ "$http_status" = "200" ]; then + highest_stable="$n" + echo "stable${n}: v${n}.0.0 released — using as highest stable" + break + else + echo "stable${n}: v${n}.0.0 not released yet (HTTP ${http_status}) — skipping" + fi + done + + if [ -z "$highest_stable" ]; then + echo "ERROR: No released stable branch found" + exit 1 + fi highest_stable_branch="stable${highest_stable}" echo "Current branch: $current_branch" - echo "Highest stable branch found: $highest_stable_branch" + echo "Highest released stable branch: $highest_stable_branch" # Map branch to deployment folder names case "$current_branch" in