@@ -19,10 +19,13 @@ using module '../PsModules/RepoBuild/RepoBuild.psd1'
1919.NOTE
2020 For the gory details of this process see: https://www.endoflineblog.com/implementing-oneflow-on-github-bitbucket-and-gitlab
2121#>
22-
22+ [ cmdletbinding ( SupportsShouldProcess = $True , ConfirmImpact = ' High ' )]
2323Param ()
2424$buildInfo = Initialize-BuildEnvironment
2525
26+ Write-Information " Build Version XML:"
27+ Write-Information ((Get-ParsedBuildVersionXML - BuildInfo $buildInfo ).GetEnumerator() | Sort - Property Name | Out-String )
28+
2629# merging the tag to develop branch on the official repository triggers the official build and release of the NuGet Packages
2730$tagName = Get-BuildVersionTag $buildInfo
2831$officialRemoteName = Get-GitRemoteName $buildInfo official
@@ -39,30 +42,42 @@ $mergeBackBranchName = "merge-back-$tagName"
3942Write-Information ' Fetching from official repository'
4043Invoke-External git fetch $officialRemoteName
4144
42- Write-Information " Switching to release branch [$officialReleaseBranch ]"
43- Invoke-External git switch ' -C' $releasebranch $officialReleaseBranch
45+ if ($PSCmdlet.ShouldProcess ($officialReleaseBranch , " git switch -C $releaseBranch " ))
46+ {
47+ Write-Information " Switching to release branch [$officialReleaseBranch ]"
48+ Invoke-External git switch ' -C' $releaseBranch $officialReleaseBranch
49+ }
4450
45- $confirmation = Read-Host " Are you Sure You Want To Proceed:"
46- if ($confirmation -ne ' y' )
51+ if ($PSCmdlet.ShouldProcess ($tagName , " create annotated tag" ))
4752{
48- Write-Host " User canceled operation "
49- return
53+ Write-Information ' Creating an annotated tag of this branch as the release '
54+ Invoke-External git tag $tagName ' -m ' " Official release: $tagName "
5055}
5156
52- Write-Information ' Creating tag of this branch as the release'
53- Invoke-External git tag $tagName ' -m' " Official release: $tagName "
57+ if ($PSCmdlet.ShouldProcess ($tagName , " git push $officialRemoteName tag" ))
58+ {
59+ Write-Information ' Pushing tag to official remote [Starts automated build release process]'
60+ Invoke-External git push $officialRemoteName tag $tagName
61+ }
5462
55- Write-Information ' Pushing tag to official remote [Starts automated build release process]'
56- Invoke-External git push $officialRemoteName ' --tags'
63+ if ($PSCmdlet.ShouldProcess ($releasebranch , " git checkout -b $mergeBackBranchName " ))
64+ {
65+ Write-Information ' Creating local merge-back branch to merge changes associated with the release'
66+ # create a "merge-back" child branch to handle any updates/conflict resolutions when applying
67+ # the changes made in the release branch back to the develop branch.
68+ Invoke-External git checkout ' -b' $mergeBackBranchName $releasebranch
69+ }
5770
58- Write-Information ' Creating local merge-back branch to merge changes associated with the release'
59- # create a "merge-back" child branch to handle any updates/conflict resolutions when applying
60- # the changes made in the release branch back to the develop branch.
61- Invoke-External git checkout ' -b' $mergeBackBranchName $releasebranch
62- Write-Information ' pushing merge-back branch to fork'
63- Invoke-External git push $forkRemoteName $mergeBackBranchName
71+ if ($PSCmdlet.ShouldProcess (" $forkRemoteName $mergeBackBranchName " , " git push" ))
72+ {
73+ Write-Information ' pushing merge-back branch to fork'
74+ Invoke-External git push $forkRemoteName $mergeBackBranchName
75+ }
6476
65- Write-Information ' Fast-forwarding main to tagged release'
66- Invoke-External git switch ' -C' $mainBranchName $officialMainBranch
67- Invoke-External git merge -- ff- only $tagName
68- Invoke-External git push $officialRemoteName $mainBranchName
77+ if ($PSCmdlet.ShouldProcess (" $tagName " , " Reset main to point to release tag" ))
78+ {
79+ Write-Information ' Updating main to point to tagged release'
80+ Invoke-External git switch ' -C' $mainBranchName $officialMainBranch
81+ Invoke-External git reset -- hard $tagName
82+ Invoke-External git push -- force $officialRemoteName $mainBranchName
83+ }
0 commit comments