Skip to content

Commit d6a2d9b

Browse files
committed
Work CI-CD
- Rework conditions for updating dependents. - PS1 to update dependents now grabs latest tag. - Rename PS1 for consistency. - Fix config for changelog generator on github releases. ***NO_CI***
1 parent 9c8abec commit d6a2d9b

File tree

2 files changed

+52
-28
lines changed

2 files changed

+52
-28
lines changed

azure-pipelines.yml

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ jobs:
179179
buildPlatform: 'x64'
180180
buildConfiguration: 'Release'
181181
solution: 'nanoFirmwareFlasher.sln'
182-
run_update_dependents: dependencies.Check_Build_Options.outputs['BuildOptions.RUN_UPDATE_DEPENDENTS']
182+
run_update_dependents: $[dependencies.Check_Build_Options.outputs['BuildOptions.RUN_UPDATE_DEPENDENTS']]
183+
isTag: $[not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))]
183184

184185
steps:
185186

@@ -196,19 +197,31 @@ jobs:
196197

197198
- task: UseDotNet@2
198199
displayName: Install .NET SDK
199-
condition: eq(variables['UPDATE_DEPENDENTS'], 'false')
200+
condition: >-
201+
and(
202+
eq(variables['isTag'], 'false'),
203+
eq(variables['UPDATE_DEPENDENTS'], 'false')
204+
)
200205
inputs:
201206
packageType: sdk
202207
version: 6.x
203208

204209
# only required when updating dependents
205210
- script: nbgv cloud -a -c
206-
condition: eq(variables['UPDATE_DEPENDENTS'], 'true')
211+
condition: >-
212+
and(
213+
eq(variables['isTag'], 'false'),
214+
eq(variables['UPDATE_DEPENDENTS'], 'false')
215+
)
207216
displayName: Set Could Version
208217

209218
- task: DotNetCoreCLI@2
210219
displayName: Restore NuGet packages
211-
condition: eq(variables['UPDATE_DEPENDENTS'], 'false')
220+
condition: >-
221+
and(
222+
eq(variables['isTag'], 'false'),
223+
eq(variables['UPDATE_DEPENDENTS'], 'false')
224+
)
212225
inputs:
213226
command: restore
214227
verbosityRestore: minimal
@@ -218,16 +231,25 @@ jobs:
218231

219232
- script: dotnet build -c $(BuildConfiguration) /p:PublicRelease=true --no-restore /t:build,pack
220233
displayName: Build NuGet package
221-
condition: eq(variables['UPDATE_DEPENDENTS'], 'false')
234+
condition: >-
235+
and(
236+
eq(variables['isTag'], 'false'),
237+
eq(variables['UPDATE_DEPENDENTS'], 'false')
238+
)
222239
223240
- script: dotnet pack --runtime win-x64 -c $(BuildConfiguration) -p:PublicRelease=true -p:PackGlobalTool=true --no-restore
224241
displayName: Build .NET Core Tool NuGet package
225-
condition: eq(variables['UPDATE_DEPENDENTS'], 'false')
242+
condition: >-
243+
and(
244+
eq(variables['isTag'], 'false'),
245+
eq(variables['UPDATE_DEPENDENTS'], 'false')
246+
)
226247
227248
- task: PowerShell@2
228249
condition: >-
229250
and(
230251
succeeded(),
252+
eq(variables['isTag'], 'false'),
231253
eq(variables['UPDATE_DEPENDENTS'], 'false')
232254
)
233255
displayName: Get NuGet build number
@@ -252,6 +274,7 @@ jobs:
252274
and(
253275
succeeded(),
254276
ne(variables['system.pullrequest.isfork'], true),
277+
eq(variables['isTag'], 'false'),
255278
eq(variables['UPDATE_DEPENDENTS'], 'false')
256279
)
257280
displayName: Update cloud build number
@@ -280,12 +303,17 @@ jobs:
280303
}
281304
282305
displayName: set release draft var
283-
condition: eq(variables['UPDATE_DEPENDENTS'], 'false')
306+
condition: >-
307+
and(
308+
eq(variables['isTag'], 'false'),
309+
eq(variables['UPDATE_DEPENDENTS'], 'false')
310+
)
284311
285312
- task: CopyFiles@1
286313
condition: >-
287314
and(
288315
succeeded(),
316+
eq(variables['isTag'], 'false'),
289317
eq(variables['UPDATE_DEPENDENTS'], 'false')
290318
)
291319
displayName: Collecting deployable artifacts
@@ -302,6 +330,7 @@ jobs:
302330
and(
303331
succeeded(),
304332
eq(variables['System.PullRequest.PullRequestId'], ''),
333+
eq(variables['isTag'], 'false'),
305334
eq(variables['UPDATE_DEPENDENTS'], 'false')
306335
)
307336
inputs:
@@ -326,14 +355,15 @@ jobs:
326355
and(
327356
succeeded(),
328357
eq(variables['System.PullRequest.PullRequestId'], ''),
358+
eq(variables['isTag'], 'false'),
329359
eq(variables['UPDATE_DEPENDENTS'], 'false')
330360
)
331-
332361
# publish artifacts
333362
- task: PublishBuildArtifacts@1
334363
condition: >-
335364
and(
336365
succeeded(),
366+
eq(variables['isTag'], 'false'),
337367
eq(variables['UPDATE_DEPENDENTS'], 'false')
338368
)
339369
displayName: Publish deployables artifacts
@@ -348,7 +378,7 @@ jobs:
348378
and(
349379
succeeded(),
350380
eq(variables['System.PullRequest.PullRequestId'], ''),
351-
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')),
381+
eq(variables['isTag'], 'false'),
352382
eq(variables['UPDATE_DEPENDENTS'], 'false')
353383
)
354384
displayName: Push nanoff NuGet package to NuGet
@@ -367,7 +397,7 @@ jobs:
367397
and(
368398
succeeded(),
369399
eq(variables['System.PullRequest.PullRequestId'], ''),
370-
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')),
400+
eq(variables['isTag'], 'false'),
371401
eq(variables['UPDATE_DEPENDENTS'], 'false')
372402
)
373403
displayName: Push library NuGet package to NuGet
@@ -385,7 +415,7 @@ jobs:
385415
condition: >-
386416
and(
387417
succeeded(),
388-
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')),
418+
eq(variables['isTag'], 'false'),
389419
eq(variables['System.PullRequest.PullRequestId'], ''),
390420
eq(variables['UPDATE_DEPENDENTS'], 'false')
391421
)
@@ -400,7 +430,6 @@ jobs:
400430
action: create
401431
isDraft: false
402432
addChangeLog: true
403-
changeLogType: issueBased
404433
changeLogLabels: |
405434
[
406435
{ "label" : "Type: bug", "displayName" : "Bugs fixed", "state" : "closed" },
@@ -413,19 +442,17 @@ jobs:
413442
# update dependencies
414443
- task: PowerShell@2
415444
condition: >-
416-
and(
417-
or(
418-
eq(variables['UPDATE_DEPENDENTS'], 'true'),
419-
eq(variables['run_update_dependents'], 'true')
420-
),
421-
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
445+
or(
446+
eq(variables['UPDATE_DEPENDENTS'], 'true'),
447+
eq(variables['run_update_dependents'], 'true'),
448+
eq(variables['isTag'], 'true')
422449
)
423450
displayName: Update dependent tools
424451
inputs:
425452
targetType: filePath
426-
filePath: azure-pipelines/update-dependencies.ps1
453+
filePath: azure-pipelines/update-dependents.ps1
427454
env:
428-
MY_GITHUB_TOKEN: $(GitHubToken)
455+
GH_TOKEN: $(GitHubToken)
429456

430457
##################################
431458
# report build failure to Discord

azure-pipelines/update-dependencies.ps1 renamed to azure-pipelines/update-dependents.ps1

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22

33
# compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
44
# 'encoded token' is the Base64 of the string "nfbot:personal-token"
5-
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$env:MY_GITHUB_TOKEN"))))"
6-
7-
# because it can take sometime for the package to become available on the NuGet providers
8-
# need to hang in here for 1 minute (1 * 60)
9-
"Waiting 1 minute to let package process flow in Azure Artifacts feed..." | Write-Host
10-
Start-Sleep -Seconds 60
5+
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$env:GH_TOKEN"))))"
116

127
# init/reset these
138
$commitMessage = ""
149
$prTitle = ""
1510
$newBranchName = "develop-nfbot/update-dependencies/" + [guid]::NewGuid().ToString()
16-
$packageTargetVersion = $env:NBGV_NuGetPackageVersion
11+
$packageTargetVersion = gh release view --json tagName --jq .tagName
1712

1813
# working directory is agent temp directory
1914
Write-Debug "Changing working directory to $env:Agent_TempDirectory"
@@ -42,7 +37,9 @@ Write-Host "Updating nanoFramework.Tools.FirmwareFlasher version in VS Code exte
4237

4338
Set-Location nanoFirmwareFlasher | Out-Null
4439

45-
git checkout --quiet tags/v$packageTargetVersion
40+
git checkout --quiet tags/$packageTargetVersion
41+
42+
Set-Location .. | Out-Null
4643

4744
#####################
4845

0 commit comments

Comments
 (0)