|
| 1 | +. .\buildutils.ps1 |
| 2 | +$buildInfo = Initialize-BuildEnvironment |
| 3 | + |
| 4 | +# determine release tag from the build version XML file in the branch |
| 5 | +[xml]$buildVersionXml = Get-Content .\BuildVersion.xml |
| 6 | +$buildVersionData = $buildVersionXml.BuildVersionData |
| 7 | +$preReleaseSuffix="" |
| 8 | +if(![string]::IsNullOrWhiteSpace($buildVersionData.PreReleaseName)) |
| 9 | +{ |
| 10 | + $preReleaseSuffix = "-$($buildVersionData.PreReleaseName)" |
| 11 | + if(![string]::IsNullOrWhiteSpace($buildVersionData.PreReleaseNumber)) |
| 12 | + { |
| 13 | + $preReleaseSuffix += ".$($buildVersionData.PreReleaseNumber)" |
| 14 | + if(![string]::IsNullOrWhiteSpace($buildVersionData.PreReleaseFix)) |
| 15 | + { |
| 16 | + $preReleaseSuffix += ".$($buildVersionData.PreReleaseFix)" |
| 17 | + } |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +# Release tags must only be pushed from a repository with the official GitHub repository as the origin remote. |
| 22 | +# This ensures that the links to source in the generated docs will have the correct URLs |
| 23 | +# (e.g. docs pushed to the official repository MUST not have links to source in some private fork) |
| 24 | +$remoteUrl = git ls-remote --get-url |
| 25 | + |
| 26 | +Write-Information "Remote URL: $remoteUrl" |
| 27 | + |
| 28 | +if($remoteUrl -ine "https://github.com/UbiquityDotNET/Llvm.NET.git") |
| 29 | +{ |
| 30 | + throw "Publishing a release tag is only allowed when the origin remote is the official source release current remote is '$remoteUrl'" |
| 31 | +} |
| 32 | + |
| 33 | +# pushing the tag to GitHub triggers the official build and release of the Nuget Packages |
| 34 | +$tagName = "v$($buildVersionData.BuildMajor).$($buildVersionData.BuildMinor).$($buildVersionData.BuildPatch)$preReleaseSuffix" |
| 35 | +$releaseBranch = "release/$tagName" |
| 36 | +$currentBranch = git rev-parse --abbrev-ref HEAD |
| 37 | +if( $releaseBranch -ne $currentBranch ) |
| 38 | +{ |
| 39 | + throw "Current branch '$currentBranch' doesn't match the expected release branch from BuildVersion.xml, expected '$releaseBranch'" |
| 40 | +} |
| 41 | + |
| 42 | +$localCommitSha = git rev-parse --verify $releaseBranch |
| 43 | +$remoteCommitSha = git rev-parse --verify "origin/$releaseBranch" |
| 44 | +if( $localCommitSha -ne $remoteCommitSha ) |
| 45 | +{ |
| 46 | + throw "Local HEAD is not the same as origin, these must be in sync so that only the tag itself is pushed" |
| 47 | +} |
| 48 | + |
| 49 | +git tag -a $tagname -m "Official release: $tagname" |
| 50 | +git checkout develop |
| 51 | +git merge $releaseBranch |
| 52 | +git push --tags origin develop |
| 53 | +git branch -d $releaseBranch |
| 54 | +git push origin --delete $releaseBranch |
| 55 | + |
| 56 | +# update master branch to point to the latest release for full releases |
| 57 | +git checkout master |
| 58 | +git merge -ff-only $tagName |
| 59 | +git push |
0 commit comments