diff --git a/.github/workflows/release-notes-check.yml b/.github/workflows/release-notes-check.yml new file mode 100644 index 000000000..afc8c33ed --- /dev/null +++ b/.github/workflows/release-notes-check.yml @@ -0,0 +1,50 @@ +name: Check release_notes.md is updated + +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 ] + types: [labeled, unlabeled, synchronize] # Trigger on PR labeling events, or a PR push (synchronize) + paths: + - '.github/workflows/release-notes-check.yml' + - '.github/workflows/version-check.yml' + +jobs: + build: + runs-on: ubuntu-latest + # Skip all validation if label 'no-release-notes' is applied to the PR + if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-release-notes') }} + steps: + - uses: actions/checkout@v2 + + - name: Check `release_notes.md` + id: check_changes + shell: pwsh + run: | + + Write-Host "Checking for changes in release_notes.md..." + + # `github.sha` is documented here : https://docs.github.com/en/actions/learn-github-actions/contexts#github-context + # `github.event.before` is documented here (under "Webhook payload object for push"): https://docs.github.com/en/webhooks/webhook-events-and-payloads#push + $latestCommitInPR = "${{ github.sha }}" + $latestCommitInTargetBranch = "${{ github.event.before }}" + + # Get list of files changed in this PR + $changedFiles = git diff --name-only latestCommitInTargetBranch $latestCommitInPR + + # If `release_notes.md` was modified, the PR passes the validation. + # If it's not modified, fail and instruct author on what to do (either modify it or add 'no-release-notes' label) + if ($changedFiles -match "release_notes.md") { + Write-Host "release_notes.md was modified. Pass!" + } else { + $errorMessage = "This PR does not update `release_notes.md`. If the PR should be included " + + "in the next release's release notes, please update this file. If the PR should not be included, " + + "then please add the label `no-release-notes` to the PR." + Write-Error $errorMessage + exit 1 # Fail the GH action + } \ No newline at end of file diff --git a/.github/workflows/version-check.yml b/.github/workflows/version-check.yml new file mode 100644 index 000000000..46f1528dc --- /dev/null +++ b/.github/workflows/version-check.yml @@ -0,0 +1,126 @@ +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 ] + types: [labeled, unlabeled, synchronize] # Trigger on PR labeling events, or a PR push (synchronize) + paths: + - '.github/workflows/release-notes-check.yml' + - '.github/workflows/version-check.yml' + +jobs: + build: + runs-on: ubuntu-latest + # Skip all validation if label 'version-already-correct' is applied to the PR + if: ${{ !contains(github.event.pull_request.labels.*.name, 'version-already-correct') }} + steps: + - uses: actions/checkout@v2 + - name: Ensure a label is provided + if: ${{ !contains(github.event.pull_request.labels.*.name, 'major-pr') }} && + ${{ !contains(github.event.pull_request.labels.*.name, 'minor-pr') }} && + ${{ !contains(github.event.pull_request.labels.*.name, 'patch-pr') }} && + shell: pwsh + run: | + $errorMessage = "This PR does not include either the 'major-pr', 'minor-pr', or 'patch-pr' labels, "+ + "which correspond to whether this change warrants a major, minor, or patch version increase over the "+ + "last release, nor does it include a 'version-already-correct' label, indicating the WebJobs extension "+ + "version is correct as-is. Label this PR with one of those four labels to proceed." + Write-Error $errorMessage + - name: Obtain version in csproj and version of latest tag + 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 + "PROJ_VERSION=$projectVersion" | Out-File -Append -FilePath $Env:GITHUB_ENV + + + # 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 + "MIN_VERSION=$minVersion" | Out-File -Append -FilePath $Env:GITHUB_ENV + + + # Split the version number by '.' character + $versionParts = $latestTag -split '\.' + + # decompose the tag + $tagMajor = $versionParts[0] + $tagMinor = $versionParts[1] + $tagPatch = $versionParts[2] + + # Set version components as environment variables for future use + "TAG_MAJOR=$($versionParts[0])" | Out-File -Append -FilePath $Env:GITHUB_ENV + "TAG_MINOR=$($versionParts[1])" | Out-File -Append -FilePath $Env:GITHUB_ENV + "TAG_PATCH=$($versionParts[2])" | Out-File -Append -FilePath $Env:GITHUB_ENV + + "PROJ_MAJOR=$($tagMajor)" | Out-File -Append -FilePath $Env:GITHUB_ENV + "PROJ_MINOR=$($tagMinor)" | Out-File -Append -FilePath $Env:GITHUB_ENV + "PROJ_PATCH=$($tagPatch)" | Out-File -Append -FilePath $Env:GITHUB_ENV + + # Compare the project version to the minimum required version + if ($projectVersion -lt $minVersion) { + Write-Error "WebJobs extension version ($projectVersion) is less than the minimum required version ($minVersion)." + exit 1 + } else { + Write-Host "WebJobs extension version ($projectVersion) meets the minimum required version ($minVersion)." + } + + - name: Check minorVersion + if: ${{ !contains(github.event.pull_request.labels.*.name, 'patch-pr') }} + shell: pwsh + run: | + # Compare the project version to the minimum required version + if ($env:PROJ_PATCH -lt $env:TAG_PATCH) { + $errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" + + "a patch-release greater than the latest tag version ($env:MIN_VERSION)." + + "Please increment the patch version or remove the `patch-pr` label." + Write-Error $errorMessage + exit 1 + } else { + Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)." + } + - name: Check minorVersion + if: ${{ !contains(github.event.pull_request.labels.*.name, 'minor-pr') }} + shell: pwsh + run: | + # Ensure that csproj is at least one minor version greater than the last release + if ($env:PROJ_MINOR -lt $env:TAG_MINOR) { + $errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" + + "a patch-release greater than the latest tag version ($env:MIN_VERSION)." + + "Please increment the patch version or remove the `patch-pr` label." + Write-Error $errorMessage + exit 1 + } else { + Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)." + } + + - name: Check majorVersion + if: ${{ !contains(github.event.pull_request.labels.*.name, 'major-pr') }} + shell: pwsh + run: | + # Ensure that csproj is at least one major version greater than the last release + if ($env:PROJ_MAJOR -lt $env:TAG_MAJOR) { + $errorMessage = "WebJobs extension version ($env:PROJ_VERSION) it not" + + "a major-release greater than the latest tag version ($env:MIN_VERSION)." + + "Please increment the patch version or remove the `patch-pr` label." + Write-Error $errorMessage + exit 1 + } else { + Write-Host "WebJobs extension version ($env:PROJ_VERSION) at least a patch-release greater than the latest tag version ($env:MIN_VERSION)." + } \ No newline at end of file diff --git a/release_notes.md b/release_notes.md index bad0e4c62..330cbd46c 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,6 @@ # Release Notes + ## Microsoft.Azure.Functions.Worker.Extensions.DurableTask 1.2.0 ### New Features