Skip to content

fix: update release #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions eng/templates/official/jobs/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ jobs:
os: linux
steps:
- powershell: |
$githubUser = "$(GithubUser)"
$githubToken = "$(GithubPat)"
$newLibraryVersion = "$(NewLibraryVersion)"

if($newLibraryVersion -match '(\d)+.(\d)+.(\d)+') {
# Create GitHub credential
git config --global user.name "AzureFunctionsPython"
git config --global user.email "[email protected]"

# 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"
Expand All @@ -29,6 +33,21 @@ jobs:
# Create release branch release/X.Y.Z
Write-Host "Creating release branch release/$newLibraryVersion"
git push --repo="https://[email protected]/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
Expand Down Expand Up @@ -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

Expand Down