Skip to content

Commit

Permalink
Improve build scripts (#146 closes #142, #143, #144, #145)
Browse files Browse the repository at this point in the history
 - Restore NuGet packages on pack
 - Skip build on branches with an active PR
 - Make AppVeyor failing builds red
 - Make tag builds fail on no recent tag
 - Upgrade to latest .NET SDK
  • Loading branch information
luigiberrettini committed Jul 4, 2018
1 parent 93f6a77 commit 30389ae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ matrix:
- os: linux
dist: trusty
mono: latest
dotnet: 2.1.3
dotnet: 2.1.201
sudo: required
env: MONO_BASE_PATH=/usr/lib/mono/
- os: osx
osx_image: xcode9.2
mono: latest
dotnet: 2.1.3
dotnet: 2.1.201
sudo: required
env: MONO_BASE_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/
before_install:
Expand All @@ -20,13 +20,15 @@ before_install:
fi
DOTNET_INSTALL_DIR="$PWD/.dotnetsdk"
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version "1.1.9" --install-dir "$DOTNET_INSTALL_DIR" --no-path
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version "2.1.200" --install-dir "$DOTNET_INSTALL_DIR" --no-path
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version "2.1.201" --install-dir "$DOTNET_INSTALL_DIR" --no-path
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version "2.1.301" --install-dir "$DOTNET_INSTALL_DIR" --no-path
export PATH="$DOTNET_INSTALL_DIR:$PATH"
script:
- |
mostRecentTag=$(git describe --abbrev=0 --tags --always)
if [[ $mostRecentTag != v* ]]; then
mostRecentTag='v1.0.0'
if [[ "${TRAVIS_TAG}" != "" ]]; then exit 1; fi
fi
mostRecentVersion=$(echo "$mostRecentTag" | cut -c 2-)
FrameworkPathOverride=$MONO_BASE_PATH/4.5.2-api/ $(pwd)/tools/build.sh '--target=Test' "--softwareVersion=$mostRecentVersion" "--buildNumber=$TRAVIS_BUILD_NUMBER"
Expand Down
6 changes: 5 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ install:
- ps: |
$DOTNET_INSTALL_DIR = $(Join-Path (Get-Location) 'dotnetsdk')
powershell -NoProfile -ExecutionPolicy Unrestricted -Command "&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 1.1.9 -InstallDir $DOTNET_INSTALL_DIR -NoPath"
powershell -NoProfile -ExecutionPolicy Unrestricted -Command "&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.200 -InstallDir $DOTNET_INSTALL_DIR -NoPath"
powershell -NoProfile -ExecutionPolicy Unrestricted -Command "&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.201 -InstallDir $DOTNET_INSTALL_DIR -NoPath"
powershell -NoProfile -ExecutionPolicy Unrestricted -Command "&([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.301 -InstallDir $DOTNET_INSTALL_DIR -NoPath"
$env:Path = "$DOTNET_INSTALL_DIR;$env:Path"
before_build:
- ps: |
$mostRecentTag = git describe --abbrev=0 --tags --always
if ($mostRecentTag.Substring(0, 1) -ne 'v') {
$mostRecentTag = 'v1.0.0'
if ($env:APPVEYOR_REPO_TAG -eq 'true') { exit 1 }
}
$mostRecentVersion = $mostRecentTag.Substring(1)
$currentCommitHash = git rev-parse --short HEAD
Set-AppveyorBuildVariable -Name SW_VER -Value $mostRecentVersion
Update-AppveyorBuild -Version "Build $env:APPVEYOR_BUILD_NUMBER - Commit $currentCommitHash - Tag v$env:SW_VER"
skip_branch_with_pr: true
build_script:
- ps: |
$additionalArgs = if ($env:APPVEYOR_REPO_TAG -ne 'true') { "--buildNumber=$env:APPVEYOR_BUILD_NUMBER" }
.\tools\build.ps1 '--target=Pack' "--softwareVersion=$env:SW_VER" $additionalArgs
if ($LastExitCode -ne 0) { exit $LastExitCode }
test: off
artifacts:
- path: tools\artifacts\*.nupkg
Expand Down
20 changes: 20 additions & 0 deletions tools/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ Task("Clean")
}
});

Task("RestorePackages")
.Does(() =>
{
var toRestoreProjects = childDirInfos
.Except(toBuildDirInfo)
.SelectMany(x => x.GetFiles("*.csproj"))
.Select(x => x.FullName)
.ToList();
var deleteDirectorySettings = new DeleteDirectorySettings
{
Recursive = true,
Force = true
};
foreach (var projectToRestore in toRestoreProjects)
DotNetCoreRestore(projectToRestore);
});

Task("Build")
.IsDependentOn("MSBuildSettings")
.Does(() =>
Expand Down Expand Up @@ -144,6 +163,7 @@ Task("Test")
});

Task("Pack")
.IsDependentOn("RestorePackages")
.IsDependentOn("Test")
.Does(() =>
{
Expand Down

0 comments on commit 30389ae

Please sign in to comment.