|
8 | 8 | os: linux |
9 | 9 | steps: |
10 | 10 | - powershell: | |
| 11 | + $githubUser = "$(GithubUser)" |
11 | 12 | $githubToken = "$(GithubPat)" |
12 | 13 | $newLibraryVersion = "$(NewLibraryVersion)" |
13 | 14 | |
14 | 15 | if($newLibraryVersion -match '(\d)+.(\d)+.(\d)+') { |
15 | 16 | # Create GitHub credential |
16 | 17 | git config --global user.name "AzureFunctionsPython" |
17 | 18 | git config --global user.email "[email protected]" |
| 19 | +
|
| 20 | + # Create GitHub credential |
| 21 | + $credential = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${githubUser}:${githubToken}")) |
18 | 22 | |
19 | 23 | # Heading to Artifact Repository |
20 | 24 | Write-Host "Operating based on $stagingDirectory/azure-functions-python-library" |
|
29 | 33 | # Create release branch release/X.Y.Z |
30 | 34 | Write-Host "Creating release branch release/$newLibraryVersion" |
31 | 35 | git push --repo="https://[email protected]/Azure/azure-functions-python-library.git" |
| 36 | +
|
| 37 | + # Create PR |
| 38 | + Write-Host "Creating PR draft in GitHub" |
| 39 | + $body = (@{head="$newBranch";base="dev";body="Python SDK Version [$newLibraryVersion]";draft=$true;maintainer_can_modify=$true;title="build: update Python SDK Version to $newLibraryVersion"} | ConvertTo-Json -Compress) |
| 40 | + $response = Invoke-WebRequest -Headers @{"Cache-Control"="no-cache";"Content-Type"="application/json";"Authorization"="Basic $credential";"Accept"="application/vnd.github.v3+json"} -Method Post -Body "$body" -Uri "https://api.github.com/repos/Azure/azure-functions-python-library/pulls" |
| 41 | + |
| 42 | + # Return Value |
| 43 | + if ($response.StatusCode -ne 201) { |
| 44 | + Write-Host "Failed to create PR in Azure Functions Python Library" |
| 45 | + exit -1 |
| 46 | + } |
| 47 | + |
| 48 | + $draftUrl = $response | ConvertFrom-Json | Select -expand url |
| 49 | + Write-Host "PR draft created in $draftUrl" |
| 50 | +
|
32 | 51 | } else { |
33 | 52 | Write-Host "NewLibraryVersion $newLibraryVersion is malformed (example: 1.5.0)" |
34 | 53 | exit -1 |
@@ -144,11 +163,11 @@ jobs: |
144 | 163 | |
145 | 164 | # Modify SDK Version in pyproject.toml |
146 | 165 | Write-Host "Replacing SDK version in worker's pyproject.toml" |
147 | | - ((Get-Content pyproject.toml) -replace '"azure-functions==(\d)+.(\d)+.*"','"azure-functions==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline pyproject.toml |
148 | | - |
| 166 | + ((Get-Content workers/pyproject.toml) -replace '"azure-functions==(\d)+.(\d)+.*"','"azure-functions==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline workers/pyproject.toml |
| 167 | +
|
149 | 168 | # Commit Python Version |
150 | 169 | Write-Host "Pushing $newBranch to azure-functions-python-worker repo" |
151 | | - git add pyproject.toml |
| 170 | + git add workers/pyproject.toml |
152 | 171 | git commit -m "Update Python SDK Version to $newLibraryVersion" |
153 | 172 | git push origin $newBranch |
154 | 173 | |
|
0 commit comments