Skip to content

Commit

Permalink
Prepare config to pack and publish NuGet package #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Marusyk committed Dec 13, 2017
1 parent de51d5c commit c8c07ea
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions build-pack-publish.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF
Powershell -File ".\build.ps1" -NugetApiKey ""
pause
18 changes: 16 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ARGUMENTS
var target = Argument("Target", "Default");
var configuration = Argument("Configuration", "Release");
var nugetApiKey = Argument("NugetApiKey", "");

// GLOBAL VARIABLES
var artifactsDirectory = Directory("./artifacts");
Expand Down Expand Up @@ -85,7 +86,7 @@ Task("Build")

Task("Pack")
.IsDependentOn("Restore")
.WithCriteria(IsOnAppVeyorAndNotPR || string.Equals(target, "pack", StringComparison.OrdinalIgnoreCase))
.WithCriteria(IsOnAppVeyorAndNotPR || !string.IsNullOrEmpty(nugetApiKey))
.Does(() =>
{
var settings = new DotNetCorePackSettings
Expand All @@ -101,11 +102,24 @@ Task("Pack")
}
});

Task("Publish")
.IsDependentOn("Pack")
.WithCriteria(IsOnAppVeyorAndNotPR || !string.IsNullOrEmpty(nugetApiKey))
.Does(() =>
{
var dir = string.Concat(artifactsDirectory, @"\*.nupkg");
NuGetPush(GetFiles(dir).First(), new NuGetPushSettings {
Source = "https://www.nuget.org/api/v2/package",
ApiKey = nugetApiKey
});
});

Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("Pack");
.IsDependentOn("Pack")
.IsDependentOn("Publish");

RunTarget(target);

Expand Down
2 changes: 2 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Param(
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
[switch]$WhatIf,
[string]$NugetApiKey,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)
Expand Down Expand Up @@ -121,6 +122,7 @@ $Arguments = @{
configuration=$Configuration;
verbosity=$Verbosity;
dryrun=$WhatIf;
nugetapikey=$NugetApiKey;
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };

# Start Cake
Expand Down
4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe
TARGET="Default"
CONFIGURATION="Release"
VERBOSITY="verbose"
NUGETAPIKEY=
DRYRUN=
SCRIPT_ARGUMENTS=()

Expand All @@ -27,6 +28,7 @@ for i in "$@"; do
-c|--configuration) CONFIGURATION="$2"; shift ;;
-v|--verbosity) VERBOSITY="$2"; shift ;;
-d|--dryrun) DRYRUN="-dryrun" ;;
-n|--nuget) NUGETAPIKEY="$2"; shift ;;
--) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
*) SCRIPT_ARGUMENTS+=("$1") ;;
esac
Expand Down Expand Up @@ -90,4 +92,4 @@ fi
###########################################################################

# Start Cake
exec mono "$CAKE_EXE" build.cake --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
exec mono "$CAKE_EXE" build.cake --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET --nuget=$NUGETAPIKEY $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
2 changes: 1 addition & 1 deletion src/Simple.HttpPatch/Simple.HttpPatch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageTags>patch; webapi; restful;</PackageTags>
<Description>Simple.HttpPatch implementation for .NET to easily allow &amp; apply partial REST-ful service (through Web API)</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.1.0-beta</Version>
<Version>1.1.1-beta</Version>
<PackageLicenseUrl>https://github.com/Marusyk/Simple.HttpPatch/blob/master/LICENSE</PackageLicenseUrl>
<PackageIconUrl>https://github.com/Marusyk/Simple.HttpPatch/blob/master/HttpPatch.png?raw=true</PackageIconUrl>
</PropertyGroup>
Expand Down

0 comments on commit c8c07ea

Please sign in to comment.