blob: bd21163c6e542022e8415930409d1f95898aae2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Tags each repo according to VersionPrefix in version.props of that repo
.PARAMETER Push
Push all updated tags
.PARAMETER ForceUpdateTag
This will call git tag --force
#>
[cmdletbinding(SupportsShouldProcess = $true)]
param(
[switch]$Push = $false,
[switch]$ForceUpdateTag = $false
)
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'
Import-Module -Scope Local -Force "$PSScriptRoot/common.psm1"
Assert-Git
$RepoRoot = Resolve-Path "$PSScriptRoot/../"
Get-Submodules $RepoRoot -Shipping | % {
Push-Location $_.path | Out-Null
try {
if (-not $_.versionPrefix) {
Write-Warning "Could not determine tag version for $(_.path)"
}
else {
$tag = $_.versionPrefix
Write-Host "$($_.module) => $tag"
$gitTagArgs = @()
if ($ForceUpdateTag) {
$gitTagArgs += '--force'
}
Invoke-Block { & git tag @gitTagArgs $tag }
if ($Push) {
$gitPushArgs = @()
if ($WhatIfPreference) {
$gitPushArgs += '--dry-run'
}
Invoke-Block { & git push --dry-run @gitPushArgs origin "refs/tags/${tag}" }
}
if ($WhatIfPreference) {
Invoke-Block { & git tag -d $tag } | Out-Null
}
}
}
catch {
Write-Host -ForegroundColor Red "Could not update $_"
throw
}
finally {
Pop-Location
}
}
|