Skip to content

Commit 87b5ca6

Browse files
authored
Improve CI & CD scripts to deal with release and master branches (#46)
1 parent b5fa478 commit 87b5ca6

File tree

4 files changed

+35
-45
lines changed

4 files changed

+35
-45
lines changed

appveyor.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ before_deploy:
7373
7474
Push-AppveyorArtifact $env:APPVEYOR_BUILD_FOLDER\source\Nuget.CoreLibrary\bin\Release\nanoFramework.CoreLibrary.$env:GitVersion_NuGetVersionV2.nupkg
7575
76+
after_deploy:
77+
# for this environment variable to work here it has to be set in AppVeyor UI
78+
- nuget push source\Nuget.CoreLibrary\bin\Release\nanoFramework.CoreLibrary.%GitVersion_NuGetVersionV2%.nupkg %MyGetToken% -Source https://www.myget.org/F/nanoframework-dev/api/v2/package
79+
- 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
80+
7681
# requires APPVEYOR_DISCORD_WEBHOOK_URL enviroment variable set with Discord webhook URL
7782
on_failure:
7883
- ps: |
@@ -132,11 +137,6 @@ for:
132137
prerelease: true
133138
force_update: true
134139

135-
after_deploy:
136-
# for this environment variable to work here it has to be set in AppVeyor UI
137-
- nuget push source\Nuget.CoreLibrary\bin\Release\nanoFramework.CoreLibrary.%GitVersion_NuGetVersionV2%.nupkg %MyGetToken% -Source https://www.myget.org/F/nanoframework-dev/api/v2/package
138-
- 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
139-
140140
-
141141
branches:
142142
only:

commit-assemblyinfo-changes.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Copyright (c) 2018 The nanoFramework project contributors
22
# See LICENSE file in the project root for full license information.
33

4-
# skip updating assembly info changes if build is a pull-request or not a tag
5-
if ($env:appveyor_pull_request_number -or $env:APPVEYOR_REPO_TAG -eq 'false')
4+
# skip updating assembly info changes if build is a pull-request or not a tag (master OR release)
5+
if ($env:appveyor_pull_request_number -or
6+
($env:APPVEYOR_REPO_BRANCH -eq "master" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or
7+
($env:APPVEYOR_REPO_BRANCH -match "^release*" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or
8+
$env:APPVEYOR_REPO_TAG -eq "true")
69
{
710
'Skip committing assembly info changes...' | Write-Host -ForegroundColor White
811
}

generate-change-log.ps1

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1-
# generate change log when build is NOT for a pull-request
2-
if ($env:appveyor_pull_request_number)
1+
# generate change log when build is NOT a pull-request or not a tag (master OR release)
2+
if ($env:appveyor_pull_request_number -or
3+
($env:APPVEYOR_REPO_BRANCH -eq "master" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or
4+
($env:APPVEYOR_REPO_BRANCH -match "^release*" -and $env:APPVEYOR_REPO_TAG -eq 'true') -or
5+
$env:APPVEYOR_REPO_TAG -eq "true")
36
{
4-
'Skip change log processing as this is a PR build...' | Write-Host -ForegroundColor White
7+
'Skip change log processing...' | Write-Host -ForegroundColor White
58
}
69
else
710
{
811
# need this to keep ruby happy
912
md c:\tmp
1013

11-
# generate change log
12-
# version includes commits
13-
bundle exec github_changelog_generator --token $env:GitHubToken
14+
if ($env:APPVEYOR_REPO_BRANCH -eq "master" -or $env:APPVEYOR_REPO_BRANCH -match "^release*")
15+
{
16+
# generate change log including future version
17+
bundle exec github_changelog_generator --token $env:GitHubToken --future-release "v$env:GitVersion_MajorMinorPatch"
18+
}
19+
else
20+
{
21+
# generate change log
22+
# version includes commits
23+
bundle exec github_changelog_generator --token $env:GitHubToken
24+
}
1425

1526
# updated changelog and the updated assembly info files
1627
git add CHANGELOG.md

update-dependencies.ps1

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Copyright (c) 2018 The nanoFramework project contributors
22
# See LICENSE file in the project root for full license information.
33

4-
# skip updating dependencies if build is a pull-request or not a tag
5-
if ($env:appveyor_pull_request_number -or $env:APPVEYOR_REPO_TAG -eq 'false')
4+
# skip updating dependencies if build is a pull-request or not a tag (master OR release)
5+
if ($env:appveyor_pull_request_number -or
6+
($env:APPVEYOR_REPO_BRANCH -eq "master" -and $env:APPVEYOR_REPO_TAG -eq 'false') -or
7+
($env:APPVEYOR_REPO_BRANCH -match "^release*" -and $env:APPVEYOR_REPO_TAG -eq 'false') -or
8+
$env:APPVEYOR_REPO_TAG -eq "false")
69
{
710
'Skip updating dependencies...' | Write-Host -ForegroundColor White
811
}
@@ -46,16 +49,7 @@ else
4649
$solutionFile = (Get-ChildItem -Path ".\" -Include "*.sln" -Recurse)
4750

4851
# run NuKeeper inspect
49-
if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH-like '*master*')
50-
{
51-
# use NuGet ONLY for release and master branches
52-
$nukeeperInspect = NuKeeper inspect --source https://api.nuget.org/v3/index.json
53-
}
54-
else
55-
{
56-
# use NuGet and MyGet for all others
57-
$nukeeperInspect = NuKeeper inspect
58-
}
52+
$nukeeperInspect = NuKeeper inspect
5953

6054
"NuGet update inspection result:" | Write-Host -ForegroundColor Cyan
6155
$nukeeperInspect | Write-Host -ForegroundColor White
@@ -71,16 +65,7 @@ else
7165
[array]$packageList = $packageListRaw.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries).Replace([Environment]::NewLine, "")
7266

7367
# restore NuGet packages, need to do this before anything else
74-
if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*')
75-
{
76-
# use NuGet ONLY for release and master branches
77-
nuget restore $solutionFile[0] -Source https://api.nuget.org/v3/index.json
78-
}
79-
else
80-
{
81-
# use NuGet and MyGet for all others
82-
nuget restore $solutionFile[0] -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json
83-
}
68+
nuget restore $solutionFile[0] -Source https://www.myget.org/F/nanoframework-dev/api/v3/index.json -Source https://api.nuget.org/v3/index.json
8469

8570
# rename nfproj files to csproj
8671
Get-ChildItem -Path ".\" -Include "*.nfproj" -Recurse |
@@ -100,16 +85,7 @@ else
10085
$packageTargetVersion = $packageDetails.captures.Groups[6].Value.Trim();
10186

10287
# update package
103-
if ($env:APPVEYOR_REPO_BRANCH -like '*release*' -or $env:APPVEYOR_REPO_BRANCH -like '*master*')
104-
{
105-
# use NuGet ONLY for release and master branches
106-
$updatePackage = nuget update $solutionFile[0].FullName -Source https://api.nuget.org/v3/index.json
107-
}
108-
else
109-
{
110-
# use NuGet and MyGet for all others
111-
$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
112-
}
88+
$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
11389

11490
# grab csproj from update output
11591
$projectPath = [regex]::Match($updatePackage, "((project ')(.*)(', targeting))").captures.Groups[3].Value

0 commit comments

Comments
 (0)