Update MicrosoftBuildVersion in analyzer template #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Version Bump Bot | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
bump-version: | |
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/bump') }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout PR branch (shallow) | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.issue.pull_request.head.ref }} | |
fetch-depth: 1 # Faster than fetch-depth: 0 | |
- name: Update Version | |
id: update-version | |
shell: pwsh | |
run: | | |
$filePath = "eng/Versions.props" | |
if (-Not (Test-Path $filePath)) { exit 0 } | |
[xml]$xml = Get-Content $filePath | |
$versionPrefix = $xml.SelectSingleNode("//VersionPrefix") | |
if ($versionPrefix -ne $null) { | |
$oldVersion = $versionPrefix.InnerText | |
$parts = $oldVersion -split '\.' | |
$newVersion = "$($parts[0]).$($parts[1]).$($parts[2] + 1)" | |
$versionPrefix.InnerText = $newVersion | |
$xml.Save($filePath) | |
echo "old_version=$oldVersion" >> $env:GITHUB_ENV | |
echo "new_version=$newVersion" >> $env:GITHUB_ENV | |
echo "changed=true" >> $env:GITHUB_ENV | |
} else { | |
echo "changed=false" >> $env:GITHUB_ENV | |
} | |
- name: Commit and Push Changes to PR branch | |
if: env.changed == 'true' | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add eng/Versions.props | |
git commit -m "bump: Update patch version from ${{ env.old_version }} to ${{ env.new_version }} | |
Triggered by: @${{ github.event.comment.user.login }} | |
Timestamp (UTC): $(date -u +"%Y-%m-%d %H:%M:%S")" | |
git push origin ${{ github.event.issue.pull_request.head.ref }} |