CI/Git.ps1
# Line break for readability in AppVeyor console Write-Host -Object '' # Make sure we're using the Master branch and that it's not a pull request # Environmental Variables Guide: https://www.appveyor.com/docs/environment-variables/ #Import-Module posh-git Write-Host "Branch is $env:APPVEYOR_REPO_BRANCH" if ($env:APPVEYOR_REPO_BRANCH -ne 'master') { Write-Warning -Message "Skipping git publish for branch $env:APPVEYOR_REPO_BRANCH" } elseif ($env:APPVEYOR_PULL_REQUEST_NUMBER -gt 0) { Write-Warning -Message "Skipping version increment and publish for pull request #$env:APPVEYOR_PULL_REQUEST_NUMBER" } else { # git tag try { # Set up a path to the git.exe cmd, import posh-git to give us control over git, and then push changes to GitHub # Note that "update version" is included in the appveyor.yml file's "skip a build" regex to avoid a loop #$env:Path += ";$env:ProgramFiles\Git\cmd" #Import-Module posh-git -ErrorAction Stop #git checkout master #git add --all #git status #git commit -s -m "Update version to $Version" $tag = "$Version-{branch}" git tag "$tag" #git push origin $tag Write-Host "Origin tagged $tag" #Write-Host "$moduleName $Version published to GitHub." -ForegroundColor Cyan } catch { # Sad panda; it broke Write-Warning "Publishing update $newVersion to GitHub failed." throw $_ } } |