Skip to content

Commit

Permalink
Add GPR publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
agc93 committed Aug 25, 2020
1 parent f7e7e0c commit 610ccbe
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
"commands": [
"dotnet-cake"
]
},
"gpr": {
"version": "0.1.224",
"commands": [
"gpr"
]
}
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,5 @@ MigrationBackup/
FodyWeavers.xsd

dist/**
build/.dotnet/**
build/.dotnet/**
tools/**
31 changes: 31 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#load "build/version.cake"
#tool "nuget:https://api.nuget.org/v3/index.json?package=nuget.commandline&version=5.3.1"

#module nuget:?package=Cake.DotNetTool.Module&version=0.4.0
#tool dotnet:?package=gpr&version=0.1.233


///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
Expand Down Expand Up @@ -136,8 +139,36 @@ Task("Publish-NuGet-Package")
});
});

Task("Publish-GitHub-Package")
.IsDependentOn("NuGet")
.WithCriteria(() => HasEnvironmentVariable("GITHUB_REF"))
.WithCriteria(() => EnvironmentVariable("GITHUB_REF").StartsWith("refs/tags/v") || EnvironmentVariable("GITHUB_REF") == "refs/heads/develop")
.Does(() => {
// Publish to GitHub Packages
var exitCode = 0;
var pkgFiles = GetFiles($"{artifacts}package/*.nupkg");
foreach(var file in pkgFiles)
{
Information("Publishing {0}...", file.GetFilename().FullPath);
exitCode += StartProcess("dotnet",
new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("gpr")
.Append("push")
.AppendQuoted(file.FullPath)
.AppendSwitchSecret("-k", " ", EnvironmentVariable("GITHUB_TOKEN"))
}
);
}
if(exitCode != 0)
{
throw new CakeException("Could not push GitHub packages.");
}
});

Task("Release")
.IsDependentOn("Default")
.IsDependentOn("Publish-GitHub-Package")
.IsDependentOn("Publish-NuGet-Package");

Task("Default")
Expand Down

0 comments on commit 610ccbe

Please sign in to comment.