Skip to content

Commit 30e777e

Browse files
committed
Work CI-CD
- Remove tag build. - Update task conditions accordingly. - Add nanoff to update dependents. ***NO_CI***
1 parent bd7bd27 commit 30e777e

File tree

2 files changed

+117
-31
lines changed

2 files changed

+117
-31
lines changed

azure-pipelines.yml

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ trigger:
2020
- config/*
2121
- .github/*
2222

23-
tags:
24-
include:
25-
- v*
26-
2723
# PR always trigger build
2824
pr:
2925
autoCancel: true
@@ -44,7 +40,6 @@ variables:
4440
solution: 'nanoFramework.Tools.Debugger.sln'
4541
buildPlatform: 'Any CPU'
4642
buildConfiguration: 'Release'
47-
isTag: $[startsWith(variables['Build.SourceBranch'], 'refs/tags/v')]
4843

4944
steps:
5045

@@ -127,8 +122,7 @@ steps:
127122
condition: >-
128123
and(
129124
ne(variables['StartReleaseCandidate'], true),
130-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
131-
eq(variables['isTag'], 'false')
125+
ne(variables['UPDATE_DEPENDENTS'], 'true')
132126
)
133127
displayName: 'Prepare analysis on SonarCloud'
134128
inputs:
@@ -144,8 +138,7 @@ steps:
144138
and(
145139
succeeded(),
146140
ne(variables['StartReleaseCandidate'], true),
147-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
148-
eq(variables['isTag'], 'false')
141+
ne(variables['UPDATE_DEPENDENTS'], 'true')
149142
)
150143
displayName: NuGet restore
151144
inputs:
@@ -155,8 +148,7 @@ steps:
155148
condition: >-
156149
and(
157150
ne(variables['StartReleaseCandidate'], true),
158-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
159-
eq(variables['isTag'], 'false')
151+
ne(variables['UPDATE_DEPENDENTS'], 'true')
160152
)
161153
inputs:
162154
solution: '$(solution)'
@@ -175,8 +167,7 @@ steps:
175167
and(
176168
succeeded(),
177169
ne(variables['StartReleaseCandidate'], true),
178-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
179-
eq(variables['isTag'], 'false')
170+
ne(variables['UPDATE_DEPENDENTS'], 'true')
180171
)
181172
displayName: 'Run Code Analysis'
182173

@@ -185,8 +176,7 @@ steps:
185176
and(
186177
succeeded(),
187178
ne(variables['StartReleaseCandidate'], true),
188-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
189-
eq(variables['isTag'], 'false')
179+
ne(variables['UPDATE_DEPENDENTS'], 'true')
190180
)
191181
inputs:
192182
pollingTimeoutSec: '300'
@@ -196,8 +186,7 @@ steps:
196186
and(
197187
succeeded(),
198188
ne(variables['StartReleaseCandidate'], true),
199-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
200-
eq(variables['isTag'], 'false')
189+
ne(variables['UPDATE_DEPENDENTS'], 'true')
201190
)
202191
displayName: Collecting deployable artifacts
203192
inputs:
@@ -215,8 +204,7 @@ steps:
215204
succeeded(),
216205
eq(variables['StartReleaseCandidate'], false),
217206
eq(variables['System.PullRequest.PullRequestId'], ''),
218-
eq(variables['UPDATE_DEPENDENTS'], 'false'),
219-
eq(variables['isTag'], 'false')
207+
eq(variables['UPDATE_DEPENDENTS'], 'false')
220208
)
221209
inputs:
222210
command: custom
@@ -241,8 +229,7 @@ steps:
241229
succeeded(),
242230
eq(variables['StartReleaseCandidate'], false),
243231
eq(variables['System.PullRequest.PullRequestId'], ''),
244-
eq(variables['UPDATE_DEPENDENTS'], 'false'),
245-
eq(variables['isTag'], 'false')
232+
eq(variables['UPDATE_DEPENDENTS'], 'false')
246233
)
247234
248235
# publish artifacts (only possible if this is not a PR originated on a fork)
@@ -251,8 +238,7 @@ steps:
251238
and(
252239
succeeded(),
253240
ne(variables['StartReleaseCandidate'], true),
254-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
255-
eq(variables['isTag'], 'false')
241+
ne(variables['UPDATE_DEPENDENTS'], 'true')
256242
)
257243
displayName: Publish deployables artifacts
258244
inputs:
@@ -267,8 +253,7 @@ steps:
267253
succeeded(),
268254
eq(variables['System.PullRequest.PullRequestId'], ''),
269255
ne(variables['StartReleaseCandidate'], true),
270-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
271-
eq(variables['isTag'], 'false')
256+
ne(variables['UPDATE_DEPENDENTS'], 'true')
272257
)
273258
displayName: Push NuGet packages to Azure Artifacts
274259
inputs:
@@ -286,8 +271,7 @@ steps:
286271
succeeded(),
287272
eq(variables['System.PullRequest.PullRequestId'], ''),
288273
ne(variables['StartReleaseCandidate'], true),
289-
ne(variables['UPDATE_DEPENDENTS'], 'true'),
290-
eq(variables['isTag'], 'false')
274+
ne(variables['UPDATE_DEPENDENTS'], 'true')
291275
)
292276
continueOnError: true
293277
displayName: Push NuGet packages to NuGet
@@ -304,7 +288,6 @@ steps:
304288
condition: >-
305289
and(
306290
succeeded(),
307-
eq(variables['isTag'], 'false'),
308291
eq(variables['System.PullRequest.PullRequestId'], ''),
309292
eq(variables['UPDATE_DEPENDENTS'], 'false')
310293
)
@@ -333,8 +316,7 @@ steps:
333316
condition: >-
334317
or(
335318
eq(variables['UPDATE_DEPENDENTS'], 'true'),
336-
eq(variables['run_update_dependents'], 'true'),
337-
eq(variables['isTag'], 'true')
319+
eq(variables['run_update_dependents'], 'true')
338320
)
339321
displayName: Update dependent tools
340322
inputs:

azure-pipelines/update-dependents.ps1

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Write-Host "Checkout main branch..."
139139
git checkout --quiet main | Out-Null
140140

141141
dotnet remove nanoFrameworkDeployer/nanoFrameworkDeployer.csproj package nanoFramework.Tools.Debugger.Net
142-
dotnet add nanoFrameworkDeployer/nanoFrameworkDeployer.csproj package nanoFramework.Tools.Debugger.Net --prerelease
142+
dotnet add nanoFrameworkDeployer/nanoFrameworkDeployer.csproj package nanoFramework.Tools.Debugger.Net
143143

144144
"Bumping nanoFramework.Tools.Debugger to $packageTargetVersion." | Write-Host -ForegroundColor Cyan
145145

@@ -218,3 +218,107 @@ else
218218
{
219219
Write-Host "Nothing udpate at nanoFramework Deployer."
220220
}
221+
222+
#######################
223+
# nano firmware flasher
224+
225+
"**************************************************************************************" | Write-Host
226+
"Updating nanoFramework.Tools.Debugger.Net package in nano firmware flasher solution..." | Write-Host
227+
228+
Set-Location "$env:Agent_TempDirectory" | Out-Null
229+
230+
# clone repo and checkout main branch
231+
Write-Debug "Init and featch nf-Deployer repo"
232+
233+
git clone --depth 1 https://github.com/nanoframework/nanoFirmwareFlasher nanoFirmwareFlasher
234+
Set-Location nanoFirmwareFlasher | Out-Null
235+
git config --global gc.auto 0
236+
git config --global user.name nfbot
237+
git config --global user.email nanoframework@outlook.com
238+
git config --global core.autocrlf true
239+
240+
Write-Host "Checkout main branch..."
241+
git checkout --quiet main | Out-Null
242+
243+
dotnet remove nanoFirmwareFlasher.Library/nanoFirmwareFlasher.Library.csproj package nanoFramework.Tools.Debugger.Net
244+
dotnet add nanoFirmwareFlasher.Library/nanoFirmwareFlasher.Library.csproj package nanoFramework.Tools.Debugger.Net
245+
dotnet remove nanoFirmwareFlasher.Tool/nanoFirmwareFlasher.Tool.csproj package nanoFramework.Tools.Debugger.Net
246+
dotnet add nanoFirmwareFlasher.Tool/nanoFirmwareFlasher.Tool.csproj package nanoFramework.Tools.Debugger.Net
247+
248+
"Bumping nanoFramework.Tools.Debugger to $packageTargetVersion." | Write-Host -ForegroundColor Cyan
249+
250+
# build commit message
251+
$commitMessage = "Bumps nanoFramework.Tools.Debugger to $packageTargetVersion.`n"
252+
# build PR title
253+
$prTitle = "Bumps nanoFramework.Tools.Debugger to $packageTargetVersion"
254+
255+
# need this line so nfbot flags the PR appropriately
256+
$commitMessage += "`n[version update]`n`n"
257+
258+
# add this to cascade updates
259+
$commitMessage += "`n`n***UPDATE_DEPENDENTS***`n`n"
260+
261+
# better add this warning line
262+
$commitMessage += "### :warning: This is an automated update. Merge only after all tests pass. :warning:`n"
263+
264+
Write-Debug "Git branch"
265+
266+
# create branch to perform updates
267+
git branch $newBranchName
268+
269+
Write-Debug "Checkout branch"
270+
271+
# checkout branch
272+
git checkout $newBranchName
273+
274+
# check if anything was changed
275+
$repoStatus = "$(git status --short --porcelain)"
276+
277+
if ($repoStatus -ne "")
278+
{
279+
Write-Debug "Add changes"
280+
281+
# commit changes
282+
git add -A > $null
283+
284+
Write-Debug "Commit changed files"
285+
286+
git commit -m "$prTitle ***NO_CI***" -m "$commitMessage" > $null
287+
288+
Write-Debug "Push changes"
289+
290+
git -c http.extraheader="AUTHORIZATION: $auth" push --set-upstream origin $newBranchName > $null
291+
292+
# start PR
293+
# we are hardcoding to 'main' branch to have a fixed one
294+
# this is very important for tags (which don't have branch information)
295+
# considering that the base branch can be changed at the PR ther is no big deal about this
296+
$prRequestBody = @{title="$prTitle";body="$commitMessage";head="$newBranchName";base="main"} | ConvertTo-Json
297+
$githubApiEndpoint = "https://api.github.com/repos/nanoframework/nanoFirmwareFlasher/pulls"
298+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
299+
300+
$headers = @{}
301+
$headers.Add("Authorization","$auth")
302+
$headers.Add("Accept","application/vnd.github.symmetra-preview+json")
303+
304+
try
305+
{
306+
$result = Invoke-RestMethod -Method Post -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Uri $githubApiEndpoint -Header $headers -ContentType "application/json" -Body $prRequestBody
307+
'Started PR with dependencies update...' | Write-Host -NoNewline
308+
'OK' | Write-Host -ForegroundColor Green
309+
}
310+
catch
311+
{
312+
$result = $_.Exception.Response.GetResponseStream()
313+
$reader = New-Object System.IO.StreamReader($result)
314+
$reader.BaseStream.Position = 0
315+
$reader.DiscardBufferedData()
316+
$responseBody = $reader.ReadToEnd();
317+
318+
throw "Error starting PR: $responseBody"
319+
}
320+
}
321+
else
322+
{
323+
Write-Host "Nothing udpate at nano firmware flasher."
324+
}

0 commit comments

Comments
 (0)