Skip to content

Commit 34b006a

Browse files
committed
Work CI-CD
- Improvements and fixes in the update dependents PS1.
1 parent 1ac3bd8 commit 34b006a

File tree

1 file changed

+50
-40
lines changed

1 file changed

+50
-40
lines changed

azure-pipelines/update-dependents.ps1

+50-40
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ dotnet nuget add source https://pkgs.dev.azure.com/nanoframework/feed/_packaging
3737
####################
3838
# VS 2019 & 2022
3939

40-
Write-Host "Updating nanoFramework.Tools.Debugger.Net package in VS2019 & VS2022 solution..."
40+
Write-Host "Updating nanoFramework.TestFramework package in VS2019 & VS2022 solution..."
4141

42-
dotnet remove VisualStudio.Extension-2019/VisualStudio.Extension-vs2019.csproj package nanoFramework.Tools.Debugger.Net
43-
dotnet add VisualStudio.Extension-2019/VisualStudio.Extension-vs2019.csproj package nanoFramework.Tools.Debugger.Net --prerelease
44-
dotnet remove VisualStudio.Extension-2022/VisualStudio.Extension-vs2022.csproj package nanoFramework.Tools.Debugger.Net
45-
dotnet add VisualStudio.Extension-2022/VisualStudio.Extension-vs2022.csproj package nanoFramework.Tools.Debugger.Net --prerelease
42+
dotnet remove VisualStudio.Extension-2019/VisualStudio.Extension-vs2019.csproj package nanoFramework.TestFramework
43+
dotnet add VisualStudio.Extension-2019/VisualStudio.Extension-vs2019.csproj package nanoFramework.TestFramework --prerelease
44+
dotnet remove VisualStudio.Extension-2022/VisualStudio.Extension-vs2022.csproj package nanoFramework.TestFramework
45+
dotnet add VisualStudio.Extension-2022/VisualStudio.Extension-vs2022.csproj package nanoFramework.TestFramework --prerelease
4646

4747
#####################
4848

@@ -61,52 +61,62 @@ $commitMessage += "### :warning: This is an automated update. Merge only after a
6161

6262
Write-Debug "Git branch"
6363

64-
# create branch to perform updates
65-
git branch $newBranchName
64+
# check if anything was changed
65+
$repoStatus = "$(git status --short --porcelain)"
6666

67-
Write-Debug "Checkout branch"
67+
if ($repoStatus -ne "")
68+
{
69+
# create branch to perform updates
70+
git branch $newBranchName
6871

69-
# checkout branch
70-
git checkout $newBranchName
72+
Write-Debug "Checkout branch"
7173

72-
Write-Debug "Add changes"
74+
# checkout branch
75+
git checkout $newBranchName
7376

74-
# commit changes
75-
git add -A > $null
77+
Write-Debug "Add changes"
7678

77-
Write-Debug "Commit changed files"
79+
# commit changes
80+
git add -A > $null
7881

79-
git commit -m "$prTitle ***NO_CI***" -m "$commitMessage" > $null
82+
Write-Debug "Commit changed files"
8083

81-
Write-Debug "Push changes"
84+
git commit -m "$prTitle ***NO_CI***" -m "$commitMessage" > $null
8285

83-
git -c http.extraheader="AUTHORIZATION: $auth" push --set-upstream origin $newBranchName > $null
86+
Write-Debug "Push changes"
8487

85-
# start PR
86-
# we are hardcoding to 'develop' branch to have a fixed one
87-
# this is very important for tags (which don't have branch information)
88-
# considering that the base branch can be changed at the PR ther is no big deal about this
89-
$prRequestBody = @{title="$prTitle";body="$commitMessage";head="$newBranchName";base="develop"} | ConvertTo-Json
90-
$githubApiEndpoint = "https://api.github.com/repos/nanoframework/nf-Visual-Studio-extension/pulls"
91-
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
88+
git -c http.extraheader="AUTHORIZATION: $auth" push --set-upstream origin $newBranchName > $null
9289

93-
$headers = @{}
94-
$headers.Add("Authorization","$auth")
95-
$headers.Add("Accept","application/vnd.github.symmetra-preview+json")
90+
# start PR
91+
# we are hardcoding to 'develop' branch to have a fixed one
92+
# this is very important for tags (which don't have branch information)
93+
# considering that the base branch can be changed at the PR ther is no big deal about this
94+
$prRequestBody = @{title="$prTitle";body="$commitMessage";head="$newBranchName";base="develop"} | ConvertTo-Json
95+
$githubApiEndpoint = "https://api.github.com/repos/nanoframework/nf-Visual-Studio-extension/pulls"
96+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
9697

97-
try
98-
{
99-
$result = Invoke-RestMethod -Method Post -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Uri $githubApiEndpoint -Header $headers -ContentType "application/json" -Body $prRequestBody
100-
'Started PR with dependencies update...' | Write-Host -NoNewline
101-
'OK' | Write-Host -ForegroundColor Green
98+
$headers = @{}
99+
$headers.Add("Authorization","$auth")
100+
$headers.Add("Accept","application/vnd.github.symmetra-preview+json")
101+
102+
try
103+
{
104+
$result = Invoke-RestMethod -Method Post -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Uri $githubApiEndpoint -Header $headers -ContentType "application/json" -Body $prRequestBody
105+
'Started PR with dependencies update...' | Write-Host -NoNewline
106+
'OK' | Write-Host -ForegroundColor Green
107+
}
108+
catch
109+
{
110+
$result = $_.Exception.Response.GetResponseStream()
111+
$reader = New-Object System.IO.StreamReader($result)
112+
$reader.BaseStream.Position = 0
113+
$reader.DiscardBufferedData()
114+
$responseBody = $reader.ReadToEnd();
115+
116+
throw "Error starting PR: $responseBody"
117+
}
102118
}
103-
catch
119+
else
104120
{
105-
$result = $_.Exception.Response.GetResponseStream()
106-
$reader = New-Object System.IO.StreamReader($result)
107-
$reader.BaseStream.Position = 0
108-
$reader.DiscardBufferedData()
109-
$responseBody = $reader.ReadToEnd();
110-
111-
throw "Error starting PR: $responseBody"
121+
Write-Host "Nothing to udpate in Visual-Studio-extension"
112122
}

0 commit comments

Comments
 (0)