|
44 | 44 | command: custom |
45 | 45 | custom: tool |
46 | 46 | arguments: install -g nbgv |
47 | | - condition: eq( variables['StartReleaseCandidate'], true ) |
| 47 | + condition: or( eq( variables['StartReleaseCandidate'], true ), ne(variables['system.pullrequest.isfork'], true) ) |
48 | 48 | displayName: Install NBGV tool |
49 | 49 |
|
50 | 50 | - powershell: | |
|
65 | 65 | git -c http.extraheader="AUTHORIZATION: $auth" fetch --progress origin |
66 | 66 | |
67 | 67 | git checkout develop |
| 68 | + |
| 69 | + cd source |
68 | 70 |
|
69 | | - nbgv prepare-release |
| 71 | + # prepare release and capture output |
| 72 | + $release = nbgv prepare-release |
70 | 73 | |
71 | 74 | # get commit message for the merge |
72 | 75 | $commitMessage = git log -1 --pretty=%B |
|
77 | 80 | # push all changes to github |
78 | 81 | git -c http.extraheader="AUTHORIZATION: $auth" push --all origin |
79 | 82 |
|
| 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 | +
|
80 | 112 | condition: eq( variables['StartReleaseCandidate'], true ) |
81 | 113 | displayName: NBGV prepare release |
82 | 114 |
|
|
0 commit comments