From 4339cce3b0afe9665f8d5adbb04875f02091723d Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com> Date: Thu, 2 Jul 2026 02:39:09 -0300 Subject: [PATCH] chore(ci): pass sonar.projectVersion to SonarQube scan so the new-code baseline advances per release (#5880) --- .github/workflows/ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ef629cf2e..906c02bb7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -889,12 +889,28 @@ jobs: else echo "SonarQube scan skipped because SONAR_TOKEN or SONAR_HOST_URL is not configured." >> "$GITHUB_STEP_SUMMARY" fi + - name: Read project version + if: ${{ github.event_name == 'pull_request' && env.SONAR_TOKEN != '' && env.SONAR_HOST_URL != '' }} + id: pkg + run: | + VERSION="$(node -p "require('./package.json').version")" + # Harden against output injection: only accept a plain semver-ish string. + if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then + echo "Invalid package.json version: $VERSION" >&2; exit 1 + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" - name: SonarQube Scan if: ${{ github.event_name == 'pull_request' && env.SONAR_TOKEN != '' && env.SONAR_HOST_URL != '' }} uses: SonarSource/sonarqube-scan-action@v8 env: SONAR_TOKEN: ${{ env.SONAR_TOKEN }} SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} + with: + # sonar.projectVersion advances the "previous_version" new-code baseline at + # each release; without it the baseline never moves (it stays pinned to the + # analysis where the version last changed) and legacy issues pile up as + # "new code" in the quality gate. + args: -Dsonar.projectVersion=${{ steps.pkg.outputs.version }} coverage-pr-comment: name: PR Coverage Comment