From 772e06bd9e1e6e94525ab8f490c302eba863b374 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 14 Jul 2026 17:53:09 +0200 Subject: [PATCH] Skip the rebuild when rector-src main is a release tag commit A tagged main is already published by the tag build of rector-src. A dispatched build would race that build for the push to rectorphp/rector, and the loser of the race fails on a non fast forward push. Tags are resolved with git ls-remote, which lists a lightweight tag with the commit itself and an annotated tag with an extra "^{}" line, so both kinds are matched. rector-src has 36 annotated tags among 574. --- .../dispatch_build_scoped_rector.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/dispatch_build_scoped_rector.yaml b/.github/workflows/dispatch_build_scoped_rector.yaml index 2abe4ba4..8ca35aa7 100644 --- a/.github/workflows/dispatch_build_scoped_rector.yaml +++ b/.github/workflows/dispatch_build_scoped_rector.yaml @@ -15,8 +15,29 @@ jobs: runs-on: ubuntu-latest steps: + # a tagged main is already being published by the tag build of rector-src, + # dispatching a second build would race it for the push to rectorphp/rector + - + name: "Check whether rector-src main is a release tag commit" + id: release_tag + run: | + RECTOR_SRC="https://github.com/rectorphp/rector-src.git" + + MAIN_SHA=$(git ls-remote $RECTOR_SRC refs/heads/main | cut -f1) + if [ -z "$MAIN_SHA" ]; then + echo "Could not resolve rector-src main" + exit 1 + fi + + # lightweight tags are listed with the commit itself, annotated ones with a "^{}" line + if git ls-remote --tags $RECTOR_SRC | grep -q "^${MAIN_SHA}"; then + echo "rector-src main $MAIN_SHA is tagged, leaving the build to the tag itself" + echo "tagged=true" >> $GITHUB_OUTPUT + fi + - name: "Trigger build_scoped_rector.yaml in rectorphp/rector-src" + if: steps.release_tag.outputs.tagged != 'true' env: GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: gh workflow run build_scoped_rector.yaml --repo rectorphp/rector-src --ref main