-
Notifications
You must be signed in to change notification settings - Fork 31
56 lines (50 loc) · 1.94 KB
/
Copy pathcheck-version-bump.yml
File metadata and controls
56 lines (50 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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: |
# Prefer Directory.Build.props; fall back to App.csproj for branches that
# predate the version-unification refactor (PR #315).
$ddb = 'src/Directory.Build.props'
$app = 'src/PlanViewer.App/PlanViewer.App.csproj'
$path = if (Test-Path $ddb) { $ddb } else { $app }
$version = ([xml](Get-Content $path)).Project.PropertyGroup.Version | Where-Object { $_ }
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
Write-Host "PR version: $version (from $path)"
- name: Checkout main
uses: actions/checkout@v5
with:
ref: main
path: main-branch
- name: Get main version
id: main
shell: pwsh
run: |
$ddb = 'main-branch/src/Directory.Build.props'
$app = 'main-branch/src/PlanViewer.App/PlanViewer.App.csproj'
$path = if (Test-Path $ddb) { $ddb } else { $app }
$version = ([xml](Get-Content $path)).Project.PropertyGroup.Version | Where-Object { $_ }
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
Write-Host "Main version: $version (from $path)"
- 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 ($PR_VERSION) has not changed from main. Bump the version before merging to main."
exit 1
fi
echo "✅ Version bumped: $MAIN_VERSION → $PR_VERSION"