Skip to content

Commit

Permalink
Updated the scripts for Nuget Push
Browse files Browse the repository at this point in the history
  • Loading branch information
franhoey committed Jan 19, 2024
1 parent 7ec0025 commit 33b2c05
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 18 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ on:
- "feature/**"
- "release/**"
- "hotfix/**"
tags:
- "*"
paths-ignore:
- "README.md"
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-2022, ubuntu-22.04, macos-12 ]
runs-on: ubuntu-22.04

steps:
- name: Checkout the repository
Expand All @@ -36,5 +31,4 @@ jobs:
uses: cake-build/[email protected]
with:
script-path: build.cake
target: Build-And-Test
verbosity: Diagnostic
target: Build-And-Test
31 changes: 31 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deploy

on:
release:
types: [published]

env:
NugetKey: ${{ secrets.NUGET_APIKEY }}

jobs:
build:
runs-on: ubuntu-22.04

steps:
- name: Checkout the repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Fetch all tags and branches
run: git fetch --prune --unshallow
- uses: actions/[email protected]
with:
dotnet-version: |
6.0
7.0
8.0
- name: Deploy project
uses: cake-build/[email protected]
with:
script-path: build.cake
target: Deploy
arguments: |
packageversion: ${{ github.ref }}
69 changes: 60 additions & 9 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,41 @@
///////////////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var packageversion = Argument("packageversion", "0.1");

///////////////////////////////////////////////////////////////////////////////
// TASKS
// Variables and Constants
///////////////////////////////////////////////////////////////////////////////

const string BuildArtifacts = "./BuildArtifacts";

//Todo: Add test for DisableTokenReplacement
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////

Setup(context =>
{
packageversion = packageversion
.Replace("refs/tags/", "")
.TrimStart('v');
Information($"Using version: {packageversion}");
});

Task("Build")
.Does(() =>
{
DotNetClean("./src/Cake.grate/Cake.grate.csproj");
DotNetClean("./src/Cake.grate/Cake.grate.csproj");

var settings = new DotNetBuildSettings
{
Configuration = configuration
};
var settings = new DotNetBuildSettings
{
Configuration = "Release",
MSBuildSettings = new DotNetMSBuildSettings
{
Version = packageversion
}
};

DotNetBuild("./src/Cake.grate/Cake.grate.csproj", settings);
DotNetBuild("./src/Cake.grate/Cake.grate.csproj", settings);
});

Task("Test")
Expand All @@ -31,10 +46,46 @@ Task("Test")
DotNetTest("./src/Cake.grate.Tests/Cake.grate.Tests.csproj");
});

Task("Pack")
.Does(() =>
{
CleanDirectory(BuildArtifacts);

var settings = new DotNetPackSettings
{
Configuration = "Release",
OutputDirectory = BuildArtifacts,
NoBuild = true, //already built
IncludeSymbols = true,
MSBuildSettings = new DotNetMSBuildSettings
{
Version = packageversion
}
};
DotNetPack("./src/Cake.grate/Cake.grate.csproj", settings);
});

Task("Push")
.Does(() =>
{
var settings = new DotNetNuGetPushSettings
{
Source = "https://api.nuget.org/v3/index.json",
ApiKey = EnvironmentVariable<string>("NugetKey", "")
};
var packageFilePath = GetFiles($"{BuildArtifacts}/Cake.grate*.nupkg").Single();
DotNetNuGetPush(packageFilePath, settings);
});

Task("Build-And-Test")
.IsDependentOn("Build")
.IsDependentOn("Test");

Task("Deploy")
.IsDependentOn("Build-And-Test")
.IsDependentOn("Pack")
.IsDependentOn("Push");


Task("Default")
.Does(() =>
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.grate/Cake.grate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageTags>cake;addin;grate;build;cake-build;script;cake-addin</PackageTags>
<RepositoryUrl>https://github.com/cake-contrib/Cake.grate</RepositoryUrl>
<PackageReleaseNotes>https://github.com/cake-contrib/Cake.grate/releases/tag/$(Version)</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 33b2c05

Please sign in to comment.