diff --git a/eng/templates/official/jobs/publish-release.yml b/eng/templates/official/jobs/publish-release.yml index d10dadda..850a4129 100644 --- a/eng/templates/official/jobs/publish-release.yml +++ b/eng/templates/official/jobs/publish-release.yml @@ -8,6 +8,7 @@ jobs: os: linux steps: - powershell: | + $githubUser = "$(GithubUser)" $githubToken = "$(GithubPat)" $newLibraryVersion = "$(NewLibraryVersion)" @@ -15,6 +16,9 @@ jobs: # Create GitHub credential git config --global user.name "AzureFunctionsPython" git config --global user.email "azfunc@microsoft.com" + + # Create GitHub credential + $credential = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("${githubUser}:${githubToken}")) # Heading to Artifact Repository Write-Host "Operating based on $stagingDirectory/azure-functions-python-library" @@ -29,6 +33,21 @@ jobs: # Create release branch release/X.Y.Z Write-Host "Creating release branch release/$newLibraryVersion" git push --repo="https://$githubToken@github.com/Azure/azure-functions-python-library.git" + + # Create PR + Write-Host "Creating PR draft in GitHub" + $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) + $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" + + # Return Value + if ($response.StatusCode -ne 201) { + Write-Host "Failed to create PR in Azure Functions Python Library" + exit -1 + } + + $draftUrl = $response | ConvertFrom-Json | Select -expand url + Write-Host "PR draft created in $draftUrl" + } else { Write-Host "NewLibraryVersion $newLibraryVersion is malformed (example: 1.5.0)" exit -1 @@ -144,11 +163,11 @@ jobs: # Modify SDK Version in pyproject.toml Write-Host "Replacing SDK version in worker's pyproject.toml" - ((Get-Content pyproject.toml) -replace '"azure-functions==(\d)+.(\d)+.*"','"azure-functions==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline pyproject.toml - + ((Get-Content workers/pyproject.toml) -replace '"azure-functions==(\d)+.(\d)+.*"','"azure-functions==$(NewLibraryVersion)"' -join "`n") + "`n" | Set-Content -NoNewline workers/pyproject.toml + # Commit Python Version Write-Host "Pushing $newBranch to azure-functions-python-worker repo" - git add pyproject.toml + git add workers/pyproject.toml git commit -m "Update Python SDK Version to $newLibraryVersion" git push origin $newBranch