From b3c24af5ee47a282c6093697c564b26515b420e6 Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Mon, 11 May 2026 23:14:08 +0200 Subject: [PATCH] Fix pre-release version sorting and missing gh-pages branch handling Replace broken numeric field sort (sort -t. -k3,3rn) with version sort (sort -rV) which correctly handles pre-release suffixes like -alpha. Select "latest" as the first stable version, skipping pre-releases. Handle missing gh-pages branch in deploy workflow using ls-remote check with orphan worktree fallback. --- .github/scripts/generate-versions-json.sh | 12 ++++++++++-- .github/workflows/deploy-docs.yml | 8 ++++++-- .github/workflows/release.yml | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/scripts/generate-versions-json.sh b/.github/scripts/generate-versions-json.sh index 386bc0a..b478df9 100755 --- a/.github/scripts/generate-versions-json.sh +++ b/.github/scripts/generate-versions-json.sh @@ -14,11 +14,19 @@ if [[ ${#VERSIONS[@]} -eq 0 ]]; then SORTED=() else IFS=$'\n' - SORTED=($(printf '%s\n' "${VERSIONS[@]}" | sed 's/^v//' | sort -t. -k1,1rn -k2,2rn -k3,3rn | sed 's/^/v/')) + SORTED=($(printf '%s\n' "${VERSIONS[@]}" | sort -rV)) unset IFS fi -LATEST="${SORTED[0]:-}" +LATEST="" +if [[ ${#SORTED[@]} -gt 0 ]]; then + for v in "${SORTED[@]}"; do + if [[ ! "$v" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-.+ ]]; then + LATEST="$v" + break + fi + done +fi HAS_MAIN=false if [ -d "$GH_PAGES_DIR/main-branch" ]; then diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 540bb4d..a6e4fe2 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -77,8 +77,12 @@ jobs: git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - git fetch origin gh-pages - git worktree add /tmp/gh-pages gh-pages + if git ls-remote --exit-code --heads origin gh-pages >/dev/null 2>&1; then + git fetch origin gh-pages + git worktree add /tmp/gh-pages gh-pages + else + git worktree add --orphan -b gh-pages /tmp/gh-pages + fi # Copy new docs into the version subdirectory mkdir -p /tmp/gh-pages/${{ steps.target.outputs.destination }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b34b7da..7d60e40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -123,7 +123,7 @@ jobs: run: | VERSION=$(git tag -l 'lldap-operator@v*' \ | sed 's/lldap-operator@//' \ - | sort -t. -k1,1rn -k2,2rn -k3,3rn \ + | sort -rV \ | head -1) echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "Detected version: $VERSION"