From 2579c12fd6d9ceff5dd933861a8a2247e4642ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 16 Oct 2018 19:15:31 +0100 Subject: [PATCH] Improve CI & CD scripts to deal with release and master branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Simões --- appveyor.yml | 10 ++++----- commit-assemblyinfo-changes.ps1 | 7 ++++-- generate-change-log.ps1 | 23 ++++++++++++++----- update-dependencies.ps1 | 40 +++++++-------------------------- 4 files changed, 35 insertions(+), 45 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 1132a3b8..590fc60b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -73,6 +73,11 @@ before_deploy: Push-AppveyorArtifact $env:APPVEYOR_BUILD_FOLDER\source\Nuget.CoreLibrary\bin\Release\nanoFramework.CoreLibrary.$env:GitVersion_NuGetVersionV2.nupkg +after_deploy: +# for this environment variable to work here it has to be set in AppVeyor UI +- nuget push source\Nuget.CoreLibrary\bin\Release\nanoFramework.CoreLibrary.%GitVersion_NuGetVersionV2%.nupkg %MyGetToken% -Source https://www.myget.org/F/nanoframework-dev/api/v2/package +- nuget push source\Nuget.CoreLibrary.DELIVERABLES\bin\Release\nanoFramework.CoreLibrary.DELIVERABLES.%GitVersion_NuGetVersionV2%.nupkg %MyGetToken% -Source https://www.myget.org/F/nanoframework-dev/api/v2/package + # requires APPVEYOR_DISCORD_WEBHOOK_URL enviroment variable set with Discord webhook URL on_failure: - ps: | @@ -132,11 +137,6 @@ for: prerelease: true force_update: true - after_deploy: - # for this environment variable to work here it has to be set in AppVeyor UI - - nuget push source\Nuget.CoreLibrary\bin\Release\nanoFramework.CoreLibrary.%GitVersion_NuGetVersionV2%.nupkg %MyGetToken% -Source https://www.myget.org/F/nanoframework-dev/api/v2/package - - nuget push source\Nuget.CoreLibrary.DELIVERABLES\bin\Release\nanoFramework.CoreLibrary.DELIVERABLES.%GitVersion_NuGetVersionV2%.nupkg %MyGetToken% -Source https://www.myget.org/F/nanoframework-dev/api/v2/package - - branches: only: diff --git a/commit-assemblyinfo-changes.ps1 b/commit-assemblyinfo-changes.ps1 index 807e3169..7991a2e0 100644 --- a/commit-assemblyinfo-changes.ps1 +++ b/commit-assemblyinfo-changes.ps1 @@ -1,8 +1,11 @@ # Copyright (c) 2018 The nanoFramework project contributors # See LICENSE file in the project root for full license information. -# skip updating assembly info changes if build is a pull-request or not a tag -if ($env:appveyor_pull_request_number -or $env:APPVEYOR_REPO_TAG -eq 'false') +# skip updating assembly info changes if build is a pull-request or not a tag (master OR release) +if ($env:appveyor_pull_request_number -or + ($env:APPVEYOR_REPO_BRANCH -eq "master" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or + ($env:APPVEYOR_REPO_BRANCH -match "^release*" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or + $env:APPVEYOR_REPO_TAG -eq "true") { 'Skip committing assembly info changes...' | Write-Host -ForegroundColor White } diff --git a/generate-change-log.ps1 b/generate-change-log.ps1 index 6e917c06..bacb255a 100644 --- a/generate-change-log.ps1 +++ b/generate-change-log.ps1 @@ -1,16 +1,27 @@ -# generate change log when build is NOT for a pull-request -if ($env:appveyor_pull_request_number) +# generate change log when build is NOT a pull-request or not a tag (master OR release) +if ($env:appveyor_pull_request_number -or + ($env:APPVEYOR_REPO_BRANCH -eq "master" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or + ($env:APPVEYOR_REPO_BRANCH -match "^release*" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or + $env:APPVEYOR_REPO_TAG -eq "true") { - 'Skip change log processing as this is a PR build...' | Write-Host -ForegroundColor White + 'Skip change log processing...' | Write-Host -ForegroundColor White } else { # need this to keep ruby happy md c:\tmp - # generate change log - # version includes commits - bundle exec github_changelog_generator --token $env:GitHubToken + if ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -match "^release*") + { + # generate change log including future version + bundle exec github_changelog_generator --token $env:GitHubToken --future-release "v$env:GitVersion_MajorMinorPatch" + } + else + { + # generate change log + # version includes commits + bundle exec github_changelog_generator --token $env:GitHubToken + } # updated changelog and the updated assembly info files git add CHANGELOG.md diff --git a/update-dependencies.ps1 b/update-dependencies.ps1 index d8400f8d..340477e8 100644 --- a/update-dependencies.ps1 +++ b/update-dependencies.ps1 @@ -1,8 +1,11 @@ # Copyright (c) 2018 The nanoFramework project contributors # See LICENSE file in the project root for full license information. -# skip updating dependencies if build is a pull-request or not a tag -if ($env:appveyor_pull_request_number -or $env:APPVEYOR_REPO_TAG -eq 'false') +# skip updating dependencies if build is a pull-request or not a tag (master OR release) +if ($env:appveyor_pull_request_number -or + ($env:APPVEYOR_REPO_BRANCH -eq "master" -and $env:APPVEYOR_REPO_TAG -eq 'false') -or + ($env:APPVEYOR_REPO_BRANCH -match "^release*" -and $env:APPVEYOR_REPO_TAG -eq 'false') -or + $env:APPVEYOR_REPO_TAG -eq "false") { 'Skip updating dependencies...' | Write-Host -ForegroundColor White } @@ -46,16 +49,7 @@ else $solutionFile = (Get-ChildItem -Path ".\" -Include "*.sln" -Recurse) # run NuKeeper inspect - if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH-like '*master*') - { - # use NuGet ONLY for release and master branches - $nukeeperInspect = NuKeeper inspect --source https://api.nuget.org/v3/index.json - } - else - { - # use NuGet and MyGet for all others - $nukeeperInspect = NuKeeper inspect - } + $nukeeperInspect = NuKeeper inspect "NuGet update inspection result:" | Write-Host -ForegroundColor Cyan $nukeeperInspect | Write-Host -ForegroundColor White @@ -71,16 +65,7 @@ else [array]$packageList = $packageListRaw.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries).Replace([Environment]::NewLine, "") # restore NuGet packages, need to do this before anything else - if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*') - { - # use NuGet ONLY for release and master branches - nuget restore $solutionFile[0] -Source https://api.nuget.org/v3/index.json - } - else - { - # use NuGet and MyGet for all others - nuget restore $solutionFile[0] -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json - } + nuget restore $solutionFile[0] -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json # rename nfproj files to csproj Get-ChildItem -Path ".\" -Include "*.nfproj" -Recurse | @@ -100,16 +85,7 @@ else $packageTargetVersion = $packageDetails.captures.Groups[6].Value.Trim(); # update package - if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*') - { - # use NuGet ONLY for release and master branches - $updatePackage = nuget update $solutionFile[0].FullName -Source https://api.nuget.org/v3/index.json - } - else - { - # use NuGet and MyGet for all others - $updatePackage = nuget update $solutionFile[0].FullName -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json - } + $updatePackage = nuget update $solutionFile[0].FullName -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json # grab csproj from update output $projectPath = [regex]::Match($updatePackage, "((project ')(.*)(', targeting))").captures.Groups[3].Value