Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI & CD scripts to deal with release and master branches #46

Merged
merged 1 commit into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions commit-assemblyinfo-changes.ps1
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down
23 changes: 17 additions & 6 deletions generate-change-log.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down
40 changes: 8 additions & 32 deletions update-dependencies.ps1
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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 |
Expand All @@ -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
Expand Down