|
8 | 8 | os: linux
|
9 | 9 | steps:
|
10 | 10 | - powershell: |
|
| 11 | + $githubUser = "$(GithubUser)" |
| 12 | + $githubToken = "$(GithubPat)" |
11 | 13 | $githubToken = "$(GithubPat)"
|
12 | 14 | $newLibraryVersion = "$(NewLibraryVersion)"
|
13 | 15 | $extensionName= "$(ExtensionName)"
|
|
18 | 20 | git config --global user.name "AzureFunctionsPython"
|
19 | 21 | git config --global user.email "[email protected]"
|
20 | 22 |
|
| 23 | + # Create GitHub credential |
| 24 | + $credential = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${githubUser}:${githubToken}")) |
| 25 | + |
21 | 26 | # Heading to Artifact Repository
|
22 | 27 | Write-Host "Operating based on $stagingDirectory/azure-functions-python-extensions"
|
23 | 28 | git checkout -b "$extensionName/release/$newLibraryVersion"
|
|
31 | 36 | # Create release branch release/X.Y.Z
|
32 | 37 | Write-Host "Creating release branch release/$newLibraryVersion"
|
33 | 38 | git push --repo="https://[email protected]/Azure/azure-functions-python-extensions.git"
|
| 39 | +
|
| 40 | + # Create PR |
| 41 | + Write-Host "Creating PR draft in GitHub" |
| 42 | + $body = (@{head="$newBranch";base="dev";body="Python Extension [$extensionName] Version [$newLibraryVersion]";draft=$true;maintainer_can_modify=$true;title="build: update $extensionName version to $newLibraryVersion"} | ConvertTo-Json -Compress) |
| 43 | + $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-extensions/pulls" |
| 44 | + |
| 45 | + # Return Value |
| 46 | + if ($response.StatusCode -ne 201) { |
| 47 | + Write-Host "Failed to create PR in Azure Functions Python Extensions" |
| 48 | + exit -1 |
| 49 | + } |
| 50 | + |
| 51 | + $draftUrl = $response | ConvertFrom-Json | Select -expand url |
| 52 | + Write-Host "PR draft created in $draftUrl" |
| 53 | + |
34 | 54 | } else {
|
35 | 55 | Write-Host "NewLibraryVersion $newLibraryVersion is malformed (example: 1.5.0)"
|
36 | 56 | exit -1
|
|
79 | 99 |
|
80 | 100 | # Push tag to remote
|
81 | 101 | git push origin $extensionName/$newLibraryVersion
|
| 102 | +
|
82 | 103 | } else {
|
83 | 104 | Write-Host "NewLibraryVersion $newLibraryVersion is malformed (example: 1.5.0)"
|
84 | 105 | exit -1
|
@@ -153,17 +174,17 @@ jobs:
|
153 | 174 |
|
154 | 175 | # Modify Extension $extensionName Version in pyproject.toml
|
155 | 176 | Write-Host "Replacing Extension $extensionName version in worker's pyproject.toml"
|
156 |
| - ((Get-Content pyproject.toml) -replace '"$(ExtensionName)==(\d)+.(\d)+.*"','"$(ExtensionName)==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline pyproject.toml |
157 |
| - |
| 177 | + ((Get-Content workers/pyproject.toml) -replace '"$(ExtensionName)==(\d)+.(\d)+.*"','"$(ExtensionName)==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline workers/pyproject.toml |
| 178 | +
|
158 | 179 | # Commit Python Version
|
159 | 180 | Write-Host "Pushing $newBranch to azure-functions-python-worker repo"
|
160 |
| - git add pyproject.toml |
| 181 | + git add workers/pyproject.toml |
161 | 182 | git commit -m "build: update $extensionName version to $newLibraryVersion"
|
162 | 183 | git push origin $newBranch
|
163 | 184 |
|
164 | 185 | # Create PR
|
165 | 186 | Write-Host "Creating PR draft in GitHub"
|
166 |
| - $body = (@{head="$newBranch";base="dev";body="Python Extension [$extensionName] Version [$newLibraryVersion](https://github.com/Azure/azure-functions-python-extensions/releases/tag/$extensionName/$newLibraryVersion)";draft=$true;maintainer_can_modify=$true;title="buikld: update $extensionName version to $newLibraryVersion"} | ConvertTo-Json -Compress) |
| 187 | + $body = (@{head="$newBranch";base="dev";body="Python Extension [$extensionName] Version [$newLibraryVersion](https://github.com/Azure/azure-functions-python-extensions/releases/tag/$extensionName/$newLibraryVersion)";draft=$true;maintainer_can_modify=$true;title="build: update $extensionName version to $newLibraryVersion"} | ConvertTo-Json -Compress) |
167 | 188 | $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-worker/pulls"
|
168 | 189 |
|
169 | 190 | # Return Value
|
@@ -238,34 +259,3 @@ jobs:
|
238 | 259 | exit -1
|
239 | 260 | }
|
240 | 261 | displayName: 'Publish package to pypi.org'
|
241 |
| -
|
242 |
| -- job: "MergeBack" |
243 |
| - dependsOn: ['PyPIPackage'] |
244 |
| - displayName: 'Merge Back' |
245 |
| - steps: |
246 |
| - - powershell: | |
247 |
| - $githubToken = "$(GithubPat)" |
248 |
| - $newLibraryVersion = "$(newLibraryVersion)" |
249 |
| - $extensionName= "$(ExtensionName)" |
250 |
| - $extensionDirectory = "$(ExtensionDirectory)" |
251 |
| - |
252 |
| - if($newLibraryVersion -match '(\d)+.(\d)+.(\d)+') { |
253 |
| - # Create GitHub credential |
254 |
| - git config --global user.name "AzureFunctionsPython" |
255 |
| - git config --global user.email "[email protected]" |
256 |
| - |
257 |
| - # Clone Repository |
258 |
| - git clone https://[email protected]/Azure/azure-functions-python-extensions |
259 |
| - Write-Host "Cloned azure-functions-python-extensions into local" |
260 |
| - Set-Location "azure-functions-python-extensions" |
261 |
| - |
262 |
| - # Merge back to dev |
263 |
| - Write-Host "Merging $extensionName/release/$newLibraryVersion back to dev" |
264 |
| - git checkout dev |
265 |
| - git merge "origin/$extensionName/release/$newLibraryVersion" |
266 |
| - git push origin dev |
267 |
| - } else { |
268 |
| - Write-Host "newLibraryVersion $newLibraryVersion is malformed (example: 1.1.8)" |
269 |
| - exit -1 |
270 |
| - } |
271 |
| - displayName: 'Merge release/x.y.z back to dev' |
0 commit comments