Skip to content

Commit 661fd78

Browse files
committed
Work CI-CD
- Update update dependents PS1 script. ***NO_CI***
1 parent 233004d commit 661fd78

File tree

1 file changed

+55
-54
lines changed

1 file changed

+55
-54
lines changed

azure-pipelines/update-dependencies.ps1

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,22 @@ Write-Host "Checkout develop branch..."
3333
git checkout --quiet develop | Out-Null
3434

3535
####################
36-
# VS 2017
36+
# VS 2019 & 2022
3737

38-
Write-Host "Updating nanoFramework.Tools.MetadataProcessor.MsBuildTask package in VS2017 solution..."
38+
"********************************************************************************" | Write-Host
39+
"Updating nanoFramework.Tools.Debugger.Net package in VS2019 & VS2022 solution..." | Write-Host
3940

40-
dotnet remove VisualStudio.Extension\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.MsBuildTask
41+
dotnet remove VisualStudio.Extension-2019/VisualStudio.Extension-vs2019.csproj package nanoFramework.Tools.Debugger.Net
42+
dotnet add VisualStudio.Extension-2019/VisualStudio.Extension-vs2019.csproj package nanoFramework.Tools.Debugger.Net --prerelease
43+
dotnet remove VisualStudio.Extension-2022/VisualStudio.Extension-vs2022.csproj package nanoFramework.Tools.Debugger.Net
44+
dotnet add VisualStudio.Extension-2022/VisualStudio.Extension-vs2022.csproj package nanoFramework.Tools.Debugger.Net --prerelease
4145

42-
dotnet add VisualStudio.Extension\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.MsBuildTask -s "https://api.nuget.org/v3/index.json;https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json"
43-
44-
####################
45-
# VS 2019
46-
47-
Write-Host "Updating nanoFramework.Tools.MetadataProcessor.MsBuildTask package in VS2019 solution..."
48-
49-
dotnet remove VisualStudio.Extension-2019\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.MsBuildTask
50-
51-
dotnet add VisualStudio.Extension-2019\VisualStudio.Extension.csproj package nanoFramework.Tools.MetadataProcessor.MsBuildTask -s "https://api.nuget.org/v3/index.json;https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json"
52-
53-
#####################
54-
55-
"Bumping MetadataProcessor.MsBuildTask to $packageTargetVersion." | Write-Host -ForegroundColor Cyan
46+
"Bumping nanoFramework.Tools.Debugger to $packageTargetVersion." | Write-Host -ForegroundColor Cyan
5647

5748
# build commit message
58-
$commitMessage += "Bumps MetadataProcessor.MsBuildTask to $packageTargetVersion.`n"
49+
$commitMessage += "Bumps nanoFramework.Tools.Debugger to $packageTargetVersion.`n"
5950
# build PR title
60-
$prTitle = "Bumps MetadataProcessor.MsBuildTask to $packageTargetVersion"
51+
$prTitle = "Bumps nanoFramework.Tools.Debugger to $packageTargetVersion"
6152

6253
# need this line so nfbot flags the PR appropriately
6354
$commitMessage += "`n[version update]`n`n"
@@ -67,52 +58,62 @@ $commitMessage += "### :warning: This is an automated update. Merge only after a
6758

6859
Write-Debug "Git branch"
6960

70-
# create branch to perform updates
71-
git branch $newBranchName
61+
# check if anything was changed
62+
$repoStatus = "$(git status --short --porcelain)"
7263

73-
Write-Debug "Checkout branch"
64+
if ($repoStatus -ne "")
65+
{
66+
# create branch to perform updates
67+
git branch $newBranchName
7468

75-
# checkout branch
76-
git checkout $newBranchName
69+
Write-Debug "Checkout branch"
7770

78-
Write-Debug "Add changes"
71+
# checkout branch
72+
git checkout $newBranchName
7973

80-
# commit changes
81-
git add -A > $null
74+
Write-Debug "Add changes"
8275

83-
Write-Debug "Commit changed files"
76+
# commit changes
77+
git add -A > $null
8478

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

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

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

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

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

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

0 commit comments

Comments
 (0)