Skip to content

Commit 89fd0e3

Browse files
committed
Work CD-CI
- Fix release prep step. ***NO_CI*** Signed-off-by: José Simões <[email protected]>
1 parent 106fad6 commit 89fd0e3

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

azure-pipelines.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
command: custom
4545
custom: tool
4646
arguments: install -g nbgv
47-
condition: eq( variables['StartReleaseCandidate'], true )
47+
condition: or( eq( variables['StartReleaseCandidate'], true ), ne(variables['system.pullrequest.isfork'], true) )
4848
displayName: Install NBGV tool
4949

5050
- powershell: |
@@ -65,8 +65,11 @@ jobs:
6565
git -c http.extraheader="AUTHORIZATION: $auth" fetch --progress origin
6666
6767
git checkout develop
68+
69+
cd source
6870
69-
nbgv prepare-release
71+
# prepare release and capture output
72+
$release = nbgv prepare-release
7073
7174
# get commit message for the merge
7275
$commitMessage = git log -1 --pretty=%B
@@ -77,6 +80,35 @@ jobs:
7780
# push all changes to github
7881
git -c http.extraheader="AUTHORIZATION: $auth" push --all origin
7982
83+
# get release branch name
84+
$branch = $release.Split(' ')[0]
85+
86+
# start PR for release
87+
$prRequestBody = @{title="Release $branch";body="";head="$branch";base="master"} | ConvertTo-Json
88+
$githubApiEndpoint = "https://api.github.com/repos/$env:Build_Repository_Name/pulls"
89+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
90+
91+
$headers = @{}
92+
$headers.Add("Authorization","$auth")
93+
$headers.Add("Accept","application/vnd.github.symmetra-preview+json")
94+
95+
try
96+
{
97+
$result = Invoke-RestMethod -Method Post -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Uri $githubApiEndpoint -Header $headers -ContentType "application/json" -Body $prRequestBody
98+
'Started PR for new release...' | Write-Host -NoNewline
99+
'OK' | Write-Host -ForegroundColor Green
100+
}
101+
catch
102+
{
103+
$result = $_.Exception.Response.GetResponseStream()
104+
$reader = New-Object System.IO.StreamReader($result)
105+
$reader.BaseStream.Position = 0
106+
$reader.DiscardBufferedData()
107+
$responseBody = $reader.ReadToEnd();
108+
109+
"Error starting PR: $responseBody" | Write-Host -ForegroundColor Red
110+
}
111+
80112
condition: eq( variables['StartReleaseCandidate'], true )
81113
displayName: NBGV prepare release
82114

0 commit comments

Comments
 (0)