diff --git a/.github/workflows/check-version-bump.yml b/.github/workflows/check-version-bump.yml index 680664f..f556a7d 100644 --- a/.github/workflows/check-version-bump.yml +++ b/.github/workflows/check-version-bump.yml @@ -1,48 +1,70 @@ -name: Check version bump -on: - pull_request: - branches: [main] - -jobs: - check-version: - if: github.head_ref == 'dev' - runs-on: ubuntu-latest - - steps: - - name: Checkout PR branch - uses: actions/checkout@v5 - - - name: Get PR version - id: pr - shell: pwsh - run: | - $version = ([xml](Get-Content Dashboard/Dashboard.csproj)).Project.PropertyGroup.Version | Where-Object { $_ } - echo "VERSION=$version" >> $env:GITHUB_OUTPUT - Write-Host "PR version: $version" - - - name: Checkout main - uses: actions/checkout@v5 - with: - ref: main - path: main-branch - - - name: Get main version - id: main - shell: pwsh - run: | - $version = ([xml](Get-Content main-branch/Dashboard/Dashboard.csproj)).Project.PropertyGroup.Version | Where-Object { $_ } - echo "VERSION=$version" >> $env:GITHUB_OUTPUT - Write-Host "Main version: $version" - - - name: Compare versions - env: - PR_VERSION: ${{ steps.pr.outputs.VERSION }} - MAIN_VERSION: ${{ steps.main.outputs.VERSION }} - run: | - echo "Main version: $MAIN_VERSION" - echo "PR version: $PR_VERSION" - if [ "$PR_VERSION" == "$MAIN_VERSION" ]; then - echo "::error::Version in Dashboard.csproj ($PR_VERSION) has not changed from main. Bump the version before merging to main." - exit 1 - fi - echo "✅ Version bumped: $MAIN_VERSION → $PR_VERSION" +name: Check version bump +on: + pull_request: + branches: [main] + +jobs: + check-version: + if: github.head_ref == 'dev' + runs-on: ubuntu-latest + + steps: + - name: Checkout PR branch + uses: actions/checkout@v5 + + # Documentation-only PRs (e.g. a CHANGELOG correction) do not bump the + # version. The workflow still runs so the required check reports a result + # — using paths-ignore would skip the run entirely and leave the check + # stuck pending. Instead, the version comparison below is gated on whether + # any non-*.md file changed. + - name: Detect non-documentation changes + id: changes + uses: dorny/paths-filter@v3 + with: + filters: | + code: + - '**' + - '!**/*.md' + + - name: Get PR version + if: steps.changes.outputs.code == 'true' + id: pr + shell: pwsh + run: | + $version = ([xml](Get-Content Dashboard/Dashboard.csproj)).Project.PropertyGroup.Version | Where-Object { $_ } + echo "VERSION=$version" >> $env:GITHUB_OUTPUT + Write-Host "PR version: $version" + + - name: Checkout main + if: steps.changes.outputs.code == 'true' + uses: actions/checkout@v5 + with: + ref: main + path: main-branch + + - name: Get main version + if: steps.changes.outputs.code == 'true' + id: main + shell: pwsh + run: | + $version = ([xml](Get-Content main-branch/Dashboard/Dashboard.csproj)).Project.PropertyGroup.Version | Where-Object { $_ } + echo "VERSION=$version" >> $env:GITHUB_OUTPUT + Write-Host "Main version: $version" + + - name: Compare versions + if: steps.changes.outputs.code == 'true' + env: + PR_VERSION: ${{ steps.pr.outputs.VERSION }} + MAIN_VERSION: ${{ steps.main.outputs.VERSION }} + run: | + echo "Main version: $MAIN_VERSION" + echo "PR version: $PR_VERSION" + if [ "$PR_VERSION" == "$MAIN_VERSION" ]; then + echo "::error::Version in Dashboard.csproj ($PR_VERSION) has not changed from main. Bump the version before merging to main." + exit 1 + fi + echo "✅ Version bumped: $MAIN_VERSION → $PR_VERSION" + + - name: Skip notice + if: steps.changes.outputs.code != 'true' + run: echo "Only documentation (*.md) files changed — version bump check skipped."