Skip to content

Commit 59d5780

Browse files
authored
add label check
1 parent 7eca545 commit 59d5780

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

.github/workflows/guarantee-version-correctness.yml

+42-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,18 @@ jobs:
1919
if: ${{ !contains(github.event.pull_request.labels.*.name, 'version-already-correct') }}
2020
steps:
2121
- uses: actions/checkout@v2
22-
23-
- name: Check .NET project version
22+
- name: Ensure a label is provided
23+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'major-pr') }} &&
24+
${{ !contains(github.event.pull_request.labels.*.name, 'minor-pr') }} &&
25+
${{ !contains(github.event.pull_request.labels.*.name, 'patch-pr') }} &&
26+
shell: pwsh
27+
run: |
28+
$errorMessage = "This PR does not include either the 'major-pr', 'minor-pr', or 'patch-pr' labels, "+
29+
"which correspond to whether this change warrants a major, minor, or patch version increase over the "+
30+
"last release, nor does it include a 'version-already-correct' label, indicating the WebJobs extension "+
31+
"version is correct as-is. Label this PR with one of those four labels to proceed."
32+
Write-Error $errorMessage
33+
- name: Obtain version in csproj and version of latest tag
2434
shell: pwsh
2535
run: |
2636
$csprojPath = ".\src\WebJobs.Extensions.DurableTask\WebJobs.Extensions.DurableTask.csproj"
@@ -74,16 +84,42 @@ jobs:
7484
if: ${{ !contains(github.event.pull_request.labels.*.name, 'patch-pr') }}
7585
shell: pwsh
7686
run: |
77-
$tagPatch = $env:TAG_PATCH
78-
$projPatch = $env:PROJ_PATCH
79-
8087
# Compare the project version to the minimum required version
81-
if ($projPatch -lt $tagPatch) {
88+
if ($env:PROJ_PATCH -lt $env:TAG_PATCH) {
8289
$errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" +
8390
"a patch-release greater than the latest tag version ($env:MIN_VERSION)." +
8491
"Please increment the patch version or remove the `patch-pr` label."
8592
Write-Error $errorMessage
8693
exit 1
8794
} else {
8895
Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)."
96+
}
97+
- name: Check minorVersion
98+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'minor-pr') }}
99+
shell: pwsh
100+
run: |
101+
# Ensure that csproj is at least one minor version greater than the last release
102+
if ($env:PROJ_MINOR -lt $env:TAG_MINOR) {
103+
$errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" +
104+
"a patch-release greater than the latest tag version ($env:MIN_VERSION)." +
105+
"Please increment the patch version or remove the `patch-pr` label."
106+
Write-Error $errorMessage
107+
exit 1
108+
} else {
109+
Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)."
110+
}
111+
112+
- name: Check majorVersion
113+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'major-pr') }}
114+
shell: pwsh
115+
run: |
116+
# Ensure that csproj is at least one major version greater than the last release
117+
if ($env:PROJ_MAJOR -lt $env:TAG_MAJOR) {
118+
$errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" +
119+
"a major-release greater than the latest tag version ($env:MIN_VERSION)." +
120+
"Please increment the patch version or remove the `patch-pr` label."
121+
Write-Error $errorMessage
122+
exit 1
123+
} else {
124+
Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)."
89125
}

0 commit comments

Comments
 (0)