-
Notifications
You must be signed in to change notification settings - Fork 273
58 lines (48 loc) · 2.15 KB
/
guarantee-version-correctness.yml
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
57
58
name: Guarantee WebJobs Extension version is correct
on:
workflow_dispatch:
push:
branches: [ main, dev, dajusto/validate-release-notes-are-provided ]
paths:
- '*'
pull_request:
branches: [ main, dev, dajusto/validate-release-notes-are-provided ]
paths:
- '.github/workflows/guarantee-release-notes.yml'
- '.github/workflows/guarantee-version-correctness.yml'
jobs:
build:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'version-already-correct') }}
steps:
- uses: actions/checkout@v2
- name: Check .NET project version
shell: pwsh
run: |
$csprojPath = ".\src\WebJobs.Extensions.DurableTask\WebJobs.Extensions.DurableTask.csproj"
# Parse the .csproj file to reconstruct the version
[xml]$csproj = Get-Content -Path $csprojPath
$majorVersionString = $csproj.Project.PropertyGroup.MajorVersion
$minorVersionString = $csproj.Project.PropertyGroup.MinorVersion
$patchVersionString = $csproj.Project.PropertyGroup.PatchVersion
$version = "$majorVersionString.$minorVersionString.$patchVersionString"
$projectVersion = [Version]$version
# Obtain latest tag
git fetch --tags
$latestTag = git describe --tags $(git rev-list --tags --max-count=1)
Write-Output "Latest tag in the repository is $latestTag"
$latestTag = $latestTag.TrimStart('v')
$minVersion = [Version]$latestTag
# Split the version number by '.' character
$versionParts = $latestTag -split '\.'
# decompose the tag
$tagMajor = $versionParts[0]
$tagMinor = $versionParts[1]
$tagPatch = $versionParts[2]
# Compare the project version to the minimum required version
if ($projectVersion -lt $minVersion) {
Write-Error "Project version ($projectVersion) is less than the minimum required version ($minVersion)."
exit 1
} else {
Write-Host "Project version ($projectVersion) meets the minimum required version ($minVersion)."
}