pulumi/scripts/get-version.ps1
Matt Ellis e46a665ce4 Add get-version.cmd and use it
Port the .sh script to powershell and use it on Windows.
2018-03-16 16:36:27 -07:00

19 lines
545 B
PowerShell

Set-StrictMode -Version 2.0
$ErrorActionPreference="Stop"
git update-index -q --refresh
git diff-files --quiet | Out-Null
$dirtyTag=""
if ($LASTEXITCODE -ne 0) {
$dirtyTag = "-dirty"
}
try {
git describe --tags --exact-match 2>$null
# If we get here the above did not throw, so we can use the exact tag
Write-Host "$(git describe --tags --exact-match)$dirtyTag"
} catch {
# Otherwise, append the timestamp of the commit and the hash
Write-Host "$(git describe --tags --abbrev=0)-$(git show -s --format='%ct-g%h')$dirtyTag"
}