From 350e06d67c8d478cd99f88261e67d4cb7006178c Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:39:20 -0500 Subject: [PATCH] Add PR branch check and version bump check workflows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - check-pr-branch: only dev can PR to main, feature branches must target dev - check-version-bump: fails if dev→main PR has the same version as main Co-Authored-By: Claude Opus 4.6 --- .github/workflows/check-pr-branch.yml | 21 +++++++++++ .github/workflows/check-version-bump.yml | 48 ++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/check-pr-branch.yml create mode 100644 .github/workflows/check-version-bump.yml diff --git a/.github/workflows/check-pr-branch.yml b/.github/workflows/check-pr-branch.yml new file mode 100644 index 0000000..88fa6fa --- /dev/null +++ b/.github/workflows/check-pr-branch.yml @@ -0,0 +1,21 @@ +name: Check pull request target branch +on: + pull_request_target: + types: + - opened + - reopened + - synchronize + - edited +jobs: + check-branches: + runs-on: ubuntu-latest + steps: + - name: Check branches + env: + HEAD_REF: ${{ github.head_ref }} + BASE_REF: ${{ github.base_ref }} + run: | + if [ "$HEAD_REF" != "dev" ] && [ "$BASE_REF" == "main" ]; then + echo "::error::Pull requests to main are only allowed from dev. Please target the dev branch instead." + exit 1 + fi diff --git a/.github/workflows/check-version-bump.yml b/.github/workflows/check-version-bump.yml new file mode 100644 index 0000000..2a5d22a --- /dev/null +++ b/.github/workflows/check-version-bump.yml @@ -0,0 +1,48 @@ +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@v4 + + - name: Get PR version + id: pr + shell: pwsh + run: | + $version = ([xml](Get-Content src/PlanViewer.App/PlanViewer.App.csproj)).Project.PropertyGroup.Version | Where-Object { $_ } + echo "VERSION=$version" >> $env:GITHUB_OUTPUT + Write-Host "PR version: $version" + + - name: Checkout main + uses: actions/checkout@v4 + with: + ref: main + path: main-branch + + - name: Get main version + id: main + shell: pwsh + run: | + $version = ([xml](Get-Content main-branch/src/PlanViewer.App/PlanViewer.App.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 PlanViewer.App.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"