diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da64a0f..e155355 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -36,5 +31,4 @@ jobs: uses: cake-build/cake-action@v1.4.1 with: script-path: build.cake - target: Build-And-Test - verbosity: Diagnostic \ No newline at end of file + target: Build-And-Test \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..708521d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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/setup-dotnet@v4.0.0 + with: + dotnet-version: | + 6.0 + 7.0 + 8.0 + - name: Deploy project + uses: cake-build/cake-action@v1.4.1 + with: + script-path: build.cake + target: Deploy + arguments: | + packageversion: ${{ github.ref }} \ No newline at end of file diff --git a/build.cake b/build.cake index 833b6be..2326a9c 100644 --- a/build.cake +++ b/build.cake @@ -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") @@ -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("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(() => diff --git a/src/Cake.grate/Cake.grate.csproj b/src/Cake.grate/Cake.grate.csproj index 0e4d4cc..4ce915d 100644 --- a/src/Cake.grate/Cake.grate.csproj +++ b/src/Cake.grate/Cake.grate.csproj @@ -29,7 +29,7 @@ cake;addin;grate;build;cake-build;script;cake-addin https://github.com/cake-contrib/Cake.grate https://github.com/cake-contrib/Cake.grate/releases/tag/$(Version) - README.md + readme.md