diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9948f562..5d26ab04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,14 @@ name: Build on: push: + branches: + - main + - develop + - "feature/**" + - "release/**" + - "hotfix/**" + tags: + - "*" paths-ignore: - "README.md" pull_request: @@ -9,17 +17,15 @@ on: jobs: build: runs-on: ${{ matrix.os }} - #mimic "skip_branch_with_pr: true", see https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/4 - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository strategy: matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + os: [ windows-2019, ubuntu-18.04, macos-10.15 ] steps: - - uses: actions/checkout@v2.3.4 - with: - fetch-depth: 0 - ref: ${{ github.event.ref }} + - name: Checkout the repository + uses: actions/checkout@v2 + - name: Fetch all tags and branches + run: git fetch --prune --unshallow - name: Cache Tools uses: actions/cache@v2 with: @@ -31,9 +37,8 @@ jobs: script-path: recipe.cake target: CI verbosity: Diagnostic - cake-version: 0.38.4 + cake-version: 0.38.5 cake-bootstrap: true - # currently, Cake.Recipe does not upload artifacts when run on gh-actions - name: Upload Issues uses: actions/upload-artifact@v2 with: @@ -44,7 +49,7 @@ jobs: BuildArtifacts/**/coverlet/*.xml - name: Upload Packages uses: actions/upload-artifact@v2 - if: matrix.os == 'windows-latest' + if: runner.os == 'Windows' with: if-no-files-found: warn name: package diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 76ef5bf2..f2ecc046 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2 with: fetch-depth: 0 @@ -49,7 +49,7 @@ jobs: # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main - - run: ./build.ps1 + - run: ./build.ps1 --target=DotNetCore-Build shell: pwsh - name: Perform CodeQL Analysis diff --git a/GitReleaseManager.yaml b/GitReleaseManager.yaml index 962256cb..8cefb54c 100644 --- a/GitReleaseManager.yaml +++ b/GitReleaseManager.yaml @@ -8,6 +8,9 @@ create: with `#addin nuget:?package=Cake.7zip&version={milestone}`. footer-includes-milestone: true milestone-replace-text: "{milestone}" + include-sha-section: true + sha-section-heading: "SHA256 Hashes of the release artifacts" + sha-section-line-format: "- `{1}\t{0}`" export: include-created-date-in-title: true created-date-string-format: yyyy-MM-dd @@ -32,3 +35,11 @@ issue-labels-alias: - name: security header: Security plural: Security +close: + use-issue-comments: true + issue-comment: |- + :tada: This issue has been resolved in version {milestone} :tada: + The release is available on: + - [GitHub Release](https://github.com/{owner}/{repository}/releases/tag/{milestone}) + - [NuGet Package](https://www.nuget.org/packages/Cake.Bakery/{milestone}) + Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package::rocket: \ No newline at end of file diff --git a/demo/build.ps1 b/demo/build.ps1 deleted file mode 100644 index a336e298..00000000 --- a/demo/build.ps1 +++ /dev/null @@ -1,256 +0,0 @@ -########################################################################## -# This is the Cake bootstrapper script for PowerShell. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. -########################################################################## - -<# - -.SYNOPSIS -This is a Powershell script to bootstrap a Cake build. - -.DESCRIPTION -This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) -and execute your Cake build script with the parameters you provide. - -.PARAMETER Script -The build script to execute. -.PARAMETER Target -The build script target to run. -.PARAMETER Configuration -The build configuration to use. -.PARAMETER Verbosity -Specifies the amount of information to be displayed. -.PARAMETER ShowDescription -Shows description about tasks. -.PARAMETER DryRun -Performs a dry run. -.PARAMETER SkipToolPackageRestore -Skips restoring of packages. -.PARAMETER ScriptArgs -Remaining arguments are added here. - -.LINK -https://cakebuild.net - -#> - -[CmdletBinding()] -Param( - [string]$Script = "build.cake", - [string]$Target, - [string]$Configuration, - [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] - [string]$Verbosity, - [switch]$ShowDescription, - [Alias("WhatIf", "Noop")] - [switch]$DryRun, - [switch]$SkipToolPackageRestore, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$ScriptArgs -) - -# Attempt to set highest encryption available for SecurityProtocol. -# PowerShell will not set this by default (until maybe .NET 4.6.x). This -# will typically produce a message for PowerShell v2 (just an info -# message though) -try { - # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48) - # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't - # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is - # installed (.NET 4.5 is an in-place upgrade). - # PowerShell Core already has support for TLS 1.2 so we can skip this if running in that. - if (-not $IsCoreCLR) { - [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48 - } - } catch { - Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3' - } - -[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null -function MD5HashFile([string] $filePath) -{ - if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) - { - return $null - } - - [System.IO.Stream] $file = $null; - [System.Security.Cryptography.MD5] $md5 = $null; - try - { - $md5 = [System.Security.Cryptography.MD5]::Create() - $file = [System.IO.File]::OpenRead($filePath) - return [System.BitConverter]::ToString($md5.ComputeHash($file)) - } - finally - { - if ($file -ne $null) - { - $file.Dispose() - } - } -} - -function GetProxyEnabledWebClient -{ - $wc = New-Object System.Net.WebClient - $proxy = [System.Net.WebRequest]::GetSystemWebProxy() - $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials - $wc.Proxy = $proxy - return $wc -} - -Write-Host "Preparing to run build script..." - -if(!$PSScriptRoot){ - $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent -} - -$TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" -$MODULES_DIR = Join-Path $TOOLS_DIR "Modules" -$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" -$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" -$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" -$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" -$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" -$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" - -# Make sure tools folder exists -if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { - Write-Verbose -Message "Creating tools directory..." - New-Item -Path $TOOLS_DIR -Type Directory | Out-Null -} - -# Make sure that packages.config exist. -if (!(Test-Path $PACKAGES_CONFIG)) { - Write-Verbose -Message "Downloading packages.config..." - try { - $wc = GetProxyEnabledWebClient - $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) - } catch { - Throw "Could not download packages.config." - } -} - -# Try find NuGet.exe in path if not exists -if (!(Test-Path $NUGET_EXE)) { - Write-Verbose -Message "Trying to find nuget.exe in PATH..." - $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } - $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 - if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { - Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." - $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName - } -} - -# Try download NuGet.exe if not exists -if (!(Test-Path $NUGET_EXE)) { - Write-Verbose -Message "Downloading NuGet.exe..." - try { - $wc = GetProxyEnabledWebClient - $wc.DownloadFile($NUGET_URL, $NUGET_EXE) - } catch { - Throw "Could not download NuGet.exe." - } -} - -# Save nuget.exe path to environment to be available to child processed -$env:NUGET_EXE = $NUGET_EXE -$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { - "mono `"$NUGET_EXE`"" -} else { - "`"$NUGET_EXE`"" -} - -# Restore tools from NuGet? -if(-Not $SkipToolPackageRestore.IsPresent) { - Push-Location - Set-Location $TOOLS_DIR - - # Check for changes in packages.config and remove installed tools if true. - [string] $md5Hash = MD5HashFile $PACKAGES_CONFIG - if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or - ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { - Write-Verbose -Message "Missing or changed package.config hash..." - Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery | - Remove-Item -Recurse -Force - } - - Write-Verbose -Message "Restoring tools from NuGet..." - - $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet tools." - } - else - { - $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" - } - Write-Verbose -Message ($NuGetOutput | Out-String) - - Pop-Location -} - -# Restore addins from NuGet -if (Test-Path $ADDINS_PACKAGES_CONFIG) { - Push-Location - Set-Location $ADDINS_DIR - - Write-Verbose -Message "Restoring addins from NuGet..." - $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet addins." - } - - Write-Verbose -Message ($NuGetOutput | Out-String) - - Pop-Location -} - -# Restore modules from NuGet -if (Test-Path $MODULES_PACKAGES_CONFIG) { - Push-Location - Set-Location $MODULES_DIR - - Write-Verbose -Message "Restoring modules from NuGet..." - $NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occurred while restoring NuGet modules." - } - - Write-Verbose -Message ($NuGetOutput | Out-String) - - Pop-Location -} - -# Make sure that Cake has been installed. -if (!(Test-Path $CAKE_EXE)) { - Throw "Could not find Cake.exe at $CAKE_EXE" -} - -$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) { - "mono `"$CAKE_EXE`"" -} else { - "`"$CAKE_EXE`"" -} - - # Build an array (not a string) of Cake arguments to be joined later -$cakeArguments = @() -if ($Script) { $cakeArguments += "`"$Script`"" } -if ($Target) { $cakeArguments += "-target=`"$Target`"" } -if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } -if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } -if ($ShowDescription) { $cakeArguments += "-showdescription" } -if ($DryRun) { $cakeArguments += "-dryrun" } -$cakeArguments += $ScriptArgs - -# Start Cake -Write-Host "Running build script..." -Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")" -exit $LASTEXITCODE diff --git a/demo/build.sh b/demo/build.sh deleted file mode 100755 index b9e12527..00000000 --- a/demo/build.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash - -########################################################################## -# This is the Cake bootstrapper script for Linux and OS X. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. -########################################################################## - -# Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -ADDINS_DIR=$TOOLS_DIR/Addins -MODULES_DIR=$TOOLS_DIR/Modules -NUGET_EXE=$TOOLS_DIR/nuget.exe -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe -PACKAGES_CONFIG=$TOOLS_DIR/packages.config -PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum -ADDINS_PACKAGES_CONFIG=$ADDINS_DIR/packages.config -MODULES_PACKAGES_CONFIG=$MODULES_DIR/packages.config - -# Define md5sum or md5 depending on Linux/OSX -MD5_EXE= -if [[ "$(uname -s)" == "Darwin" ]]; then - MD5_EXE="md5 -r" -else - MD5_EXE="md5sum" -fi - -# Define default arguments. -SCRIPT="build.cake" -CAKE_ARGUMENTS=() - -# Parse arguments. -for i in "$@"; do - case $1 in - -s|--script) SCRIPT="$2"; shift ;; - --) shift; CAKE_ARGUMENTS+=("$@"); break ;; - *) CAKE_ARGUMENTS+=("$1") ;; - esac - shift -done - -# Make sure the tools folder exist. -if [ ! -d "$TOOLS_DIR" ]; then - mkdir "$TOOLS_DIR" -fi - -# Make sure that packages.config exist. -if [ ! -f "$TOOLS_DIR/packages.config" ]; then - echo "Downloading packages.config..." - curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages - if [ $? -ne 0 ]; then - echo "An error occurred while downloading packages.config." - exit 1 - fi -fi - -# Download NuGet if it does not exist. -if [ ! -f "$NUGET_EXE" ]; then - echo "Downloading NuGet..." - curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - if [ $? -ne 0 ]; then - echo "An error occurred while downloading nuget.exe." - exit 1 - fi -fi - -# Restore tools from NuGet. -pushd "$TOOLS_DIR" >/dev/null -if [ ! -f "$PACKAGES_CONFIG_MD5" ] || [ "$( cat "$PACKAGES_CONFIG_MD5" | sed 's/\r$//' )" != "$( $MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' )" ]; then - find . -type d ! -name . ! -name 'Cake.Bakery' | xargs rm -rf -fi - -mono "$NUGET_EXE" install -ExcludeVersion -if [ $? -ne 0 ]; then - echo "Could not restore NuGet tools." - exit 1 -fi - -$MD5_EXE "$PACKAGES_CONFIG" | awk '{ print $1 }' >| "$PACKAGES_CONFIG_MD5" - -popd >/dev/null - -# Restore addins from NuGet. -if [ -f "$ADDINS_PACKAGES_CONFIG" ]; then - pushd "$ADDINS_DIR" >/dev/null - - mono "$NUGET_EXE" install -ExcludeVersion - if [ $? -ne 0 ]; then - echo "Could not restore NuGet addins." - exit 1 - fi - - popd >/dev/null -fi - -# Restore modules from NuGet. -if [ -f "$MODULES_PACKAGES_CONFIG" ]; then - pushd "$MODULES_DIR" >/dev/null - - mono "$NUGET_EXE" install -ExcludeVersion - if [ $? -ne 0 ]; then - echo "Could not restore NuGet modules." - exit 1 - fi - - popd >/dev/null -fi - -# Make sure that Cake has been installed. -if [ ! -f "$CAKE_EXE" ]; then - echo "Could not find Cake.exe at '$CAKE_EXE'." - exit 1 -fi - -# Start Cake -exec mono "$CAKE_EXE" $SCRIPT "${CAKE_ARGUMENTS[@]}" diff --git a/demo/.gitignore b/demo/cake/.gitignore similarity index 100% rename from demo/.gitignore rename to demo/cake/.gitignore diff --git a/demo/build.cake b/demo/cake/build.cake similarity index 94% rename from demo/build.cake rename to demo/cake/build.cake index 338d46f2..d9fcd082 100644 --- a/demo/build.cake +++ b/demo/cake/build.cake @@ -1,5 +1,5 @@ #tool "nuget:?package=7-Zip.CommandLine&version=18.1.0" -#r "..\src\Cake.7zip\bin\Debug\netstandard2.0\Cake.7zip.dll" +#r "..\..\src\Cake.7zip\bin\Debug\netstandard2.0\Cake.7zip.dll" /////////////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -12,6 +12,7 @@ var target = Argument("target", "Default"); /////////////////////////////////////////////////////////////////////////////// var output = Directory("output"); +var root = Directory("../.."); /////////////////////////////////////////////////////////////////////////////// // TASKS @@ -29,8 +30,8 @@ Task("ZipIt") SevenZip(m => m .InAddMode() .WithArchive(output + File("archive.zip")) - .WithFiles(File("../README.md")) - .WithFiles(File("../CODE_OF_CONDUCT.md"))); + .WithFiles(root + File("README.md")) + .WithFiles(root + File("CODE_OF_CONDUCT.md"))); }); Task("ZipVolumes") @@ -40,7 +41,7 @@ Task("ZipVolumes") .InAddMode() .WithArchive(output + File("volume.7z")) .WithArchiveType(SwitchArchiveType.SevenZip) - .WithDirectoryContents(Directory("..")) + .WithDirectoryContents(root + Directory("src")) .WithCompressFilesOpenForWriting() .WithVolume(20, VolumeUnit.Megabytes)); }); @@ -75,7 +76,7 @@ Task("UpdateIt") SevenZip(m => m .InUpdateMode() .WithArchive(output + File("archive.zip")) - .WithFiles(File("../LICENSE.txt"))); + .WithFiles(root + File("LICENSE.txt"))); }); Task("GetInfos") diff --git a/demo/cake/build.ps1 b/demo/cake/build.ps1 new file mode 100644 index 00000000..21821d29 --- /dev/null +++ b/demo/cake/build.ps1 @@ -0,0 +1,13 @@ +$ErrorActionPreference = 'Stop' + +Set-Location -LiteralPath $PSScriptRoot + +$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1' +$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1' +$env:DOTNET_NOLOGO = '1' + +dotnet tool restore +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + +dotnet cake @args +if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } diff --git a/demo/cake/build.sh b/demo/cake/build.sh new file mode 100755 index 00000000..31be8865 --- /dev/null +++ b/demo/cake/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euox pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" + +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_NOLOGO=1 + +dotnet tool restore + +dotnet cake "$@" diff --git a/demo/frosting/.gitignore b/demo/frosting/.gitignore new file mode 100644 index 00000000..39e62022 --- /dev/null +++ b/demo/frosting/.gitignore @@ -0,0 +1,3 @@ +output/ +.idea/ +build/tools/ \ No newline at end of file diff --git a/demo/frosting/build.ps1 b/demo/frosting/build.ps1 new file mode 100644 index 00000000..a7077190 --- /dev/null +++ b/demo/frosting/build.ps1 @@ -0,0 +1,2 @@ +dotnet run --project build/Build.csproj -- $args +exit $LASTEXITCODE; \ No newline at end of file diff --git a/demo/frosting/build.sh b/demo/frosting/build.sh new file mode 100755 index 00000000..dfd6b854 --- /dev/null +++ b/demo/frosting/build.sh @@ -0,0 +1 @@ +dotnet run --project ./build/Build.csproj -- "$@" diff --git a/demo/frosting/build/Build.csproj b/demo/frosting/build/Build.csproj new file mode 100644 index 00000000..b626894d --- /dev/null +++ b/demo/frosting/build/Build.csproj @@ -0,0 +1,20 @@ + + + Exe + netcoreapp3.1 + $(MSBuildProjectDirectory).. + + + + + + + ..\..\..\src\Cake.7zip\bin\Release\netstandard2.0\Cake.7zip.dll + + + + + + + + \ No newline at end of file diff --git a/demo/frosting/build/BuildContext.cs b/demo/frosting/build/BuildContext.cs new file mode 100644 index 00000000..73b00830 --- /dev/null +++ b/demo/frosting/build/BuildContext.cs @@ -0,0 +1,18 @@ +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; + +namespace Build +{ + public class BuildContext : FrostingContext + { + public DirectoryPath Root { get; set; } + + public DirectoryPath Output { get; set; } + + public BuildContext(ICakeContext context) + : base(context) + { + } + } +} diff --git a/demo/frosting/build/BuildSetup.cs b/demo/frosting/build/BuildSetup.cs new file mode 100644 index 00000000..4d82c297 --- /dev/null +++ b/demo/frosting/build/BuildSetup.cs @@ -0,0 +1,18 @@ +using Cake.Common.Diagnostics; +using Cake.Frosting; + +namespace Build +{ + public class BuildSetup : FrostingSetup + { + public override void Setup(BuildContext context) + { + var startPath = context.Environment.WorkingDirectory; + context.Information($"Frosting was started from: {startPath}"); + context.Root = startPath.Combine("../../.."); // one more ".." than in Cake, for the "build" here.. + context.Output = startPath.Combine("output"); + } + } +} + + diff --git a/demo/frosting/build/DefaultTask.cs b/demo/frosting/build/DefaultTask.cs new file mode 100644 index 00000000..9c6bb57d --- /dev/null +++ b/demo/frosting/build/DefaultTask.cs @@ -0,0 +1,24 @@ +using Build.Tasks; +using Cake.Frosting; + +namespace Build +{ + [TaskName("Default")] + [IsDependentOn(typeof(CleanTask))] + [IsDependentOn(typeof(ZipItTask))] + [IsDependentOn(typeof(ZipVolumesTask))] + [IsDependentOn(typeof(UnzipItTask))] + [IsDependentOn(typeof(RemoveFilesTask))] + [IsDependentOn(typeof(UpdateItTask))] + [IsDependentOn(typeof(GetInfosTask))] + [IsDependentOn(typeof(TestZipTask))] + [IsDependentOn(typeof(GetHashTask))] + [IsDependentOn(typeof(DoBenchmarkTask))] + [IsDependentOn(typeof(ListArchiveContentTask))] + [IsDependentOn(typeof(RenameFileTask))] + [IsDependentOn(typeof(GH78Task))] + // ReSharper disable once UnusedType.Global + public sealed class DefaultTask : FrostingTask + { + } +} diff --git a/demo/frosting/build/Program.cs b/demo/frosting/build/Program.cs new file mode 100644 index 00000000..38cf3532 --- /dev/null +++ b/demo/frosting/build/Program.cs @@ -0,0 +1,17 @@ +using System; +using Cake.Frosting; + +namespace Build +{ + public static class Program + { + public static int Main(string[] args) + { + return new CakeHost() + .InstallTool(new Uri("nuget:?package=7-Zip.CommandLine&version=18.1.0")) + .UseContext() + .UseSetup() + .Run(args); + } + } +} diff --git a/demo/frosting/build/Tasks/CleanTask.cs b/demo/frosting/build/Tasks/CleanTask.cs new file mode 100644 index 00000000..9e772749 --- /dev/null +++ b/demo/frosting/build/Tasks/CleanTask.cs @@ -0,0 +1,14 @@ +using Cake.Common.IO; +using Cake.Frosting; + +namespace Build.Tasks +{ + [TaskName("Clean")] + public sealed class CleanTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.CleanDirectory(context.Output); + } + } +} diff --git a/demo/frosting/build/Tasks/DoBenchmarkTask.cs b/demo/frosting/build/Tasks/DoBenchmarkTask.cs new file mode 100644 index 00000000..57b3569f --- /dev/null +++ b/demo/frosting/build/Tasks/DoBenchmarkTask.cs @@ -0,0 +1,22 @@ +using Cake.Common.Diagnostics; +using Cake.Frosting; +using Cake.SevenZip; + +namespace Build.Tasks +{ + [TaskName("DoBenchmark")] + public sealed class DoBenchmarkTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => m + .InBenchmarkMode() + .WithCommandOutput(o => + { + context.Information("7Zip version is:" + o.Information); + context.Information("Benchmark results:"); + context.Information(o.Benchmark); + })); + } + } +} diff --git a/demo/frosting/build/Tasks/GH78Task.cs b/demo/frosting/build/Tasks/GH78Task.cs new file mode 100644 index 00000000..f81a6780 --- /dev/null +++ b/demo/frosting/build/Tasks/GH78Task.cs @@ -0,0 +1,22 @@ +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; +using Cake.SevenZip.Switches; + +namespace Build.Tasks +{ + [TaskName("GH78")] + [IsDependentOn(typeof(CleanTask))] + [IsDependentOn(typeof(ZipVolumesTask))] + public sealed class GH78Task : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => ArgumentArchiveBuilder.WithArchive(m + .InExtractMode(), context.Output.CombineWithFilePath("volume.7z.001")) + .WithArchiveType(SwitchArchiveType.SevenZip.Volumes()) + .WithOutputDirectory(context.Output.Combine("Test01"))); + + } + } +} diff --git a/demo/frosting/build/Tasks/GetHashTask.cs b/demo/frosting/build/Tasks/GetHashTask.cs new file mode 100644 index 00000000..c7926e77 --- /dev/null +++ b/demo/frosting/build/Tasks/GetHashTask.cs @@ -0,0 +1,29 @@ +using System.Linq; +using Cake.Common.Diagnostics; +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; +using Cake.SevenZip.Switches; + +namespace Build.Tasks +{ + [TaskName("GetHash")] + [IsDependentOn(typeof(ZipItTask))] + public sealed class GetHashTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => ArgumentFilesBuilder.WithFiles(m + .InHashMode(), context.Output.CombineWithFilePath("archive.zip")) + .WithHashFunction(SwitchSetHashFunction.All) + .WithCommandOutput(o => + { + context.Information("7Zip version is:" + o.Information); + var file = o.Files.First(); + foreach(var hash in file.Hashes){ + context.Information($"{hash.HashFunction} of {file.FilePath} is: {hash.Hash}"); + } + })); + } + } +} diff --git a/demo/frosting/build/Tasks/GetInfosTask.cs b/demo/frosting/build/Tasks/GetInfosTask.cs new file mode 100644 index 00000000..7c4f3ac5 --- /dev/null +++ b/demo/frosting/build/Tasks/GetInfosTask.cs @@ -0,0 +1,22 @@ +using System.Linq; +using Cake.Common.Diagnostics; +using Cake.Frosting; +using Cake.SevenZip; + +namespace Build.Tasks +{ + [TaskName("GetInfos")] + public sealed class GetInfosTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => m + .InInformationMode() + .WithCommandOutput(o => + { + context.Information("7Zip version is:" + o.Information); + context.Information("7Zip supports QCOW:" + (Enumerable.Any(o.Formats, x => x.IndexOf("QCOW") > -1))); + })); + } + } +} diff --git a/demo/frosting/build/Tasks/ListArchiveContentTask.cs b/demo/frosting/build/Tasks/ListArchiveContentTask.cs new file mode 100644 index 00000000..47c2e035 --- /dev/null +++ b/demo/frosting/build/Tasks/ListArchiveContentTask.cs @@ -0,0 +1,29 @@ +using System.Linq; +using Cake.Common.Diagnostics; +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; + +namespace Build.Tasks +{ + [TaskName("ListArchiveContent")] + [IsDependentOn(typeof(ZipItTask))] + public sealed class ListArchiveContentTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => m + .InListMode() + .WithArchive(context.Output.CombineWithFilePath("archive.zip")) + .WithCommandOutput(o => + { + context.Information("7Zip version is:" + o.Information); + var archive = o.Archives.Single(); // only one archive given above + foreach(var file in archive.Files) + { + context.Information($"{file.Name} has compressed size {file.CompressedSize} (of {file.Size})"); + } + })); + } + } +} diff --git a/demo/frosting/build/Tasks/RemoveFilesTask.cs b/demo/frosting/build/Tasks/RemoveFilesTask.cs new file mode 100644 index 00000000..66a5d681 --- /dev/null +++ b/demo/frosting/build/Tasks/RemoveFilesTask.cs @@ -0,0 +1,19 @@ +using Cake.Core.IO; +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; + +namespace Build.Tasks +{ + [TaskName("RemoveFiles")] + [IsDependentOn(typeof(ZipItTask))] + public sealed class RemoveFilesTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => ArgumentArchiveBuilder.WithArchive(m + .InDeleteMode(), context.Output.CombineWithFilePath("archive.zip")) + .WithFiles(FilePath.FromString("README.md"))); + } + } +} diff --git a/demo/frosting/build/Tasks/RenameFileTask.cs b/demo/frosting/build/Tasks/RenameFileTask.cs new file mode 100644 index 00000000..cfb3b5ca --- /dev/null +++ b/demo/frosting/build/Tasks/RenameFileTask.cs @@ -0,0 +1,21 @@ +using Cake.Core.IO; +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; + +namespace Build.Tasks +{ + [TaskName("RenameFile")] +//[IsDependentOn(typeof(OtherTask))] + public sealed class RenameFileTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => ArgumentArchiveBuilder.WithArchive(m + .InRenameMode(), context.Output.CombineWithFilePath("archive.zip")) + .WithRenameFile( + FilePath.FromString("CODE_OF_CONDUCT.md"), + FilePath.FromString("CODE_OF_CONDUCT.txt"))); + } + } +} diff --git a/demo/frosting/build/Tasks/TestZipTask.cs b/demo/frosting/build/Tasks/TestZipTask.cs new file mode 100644 index 00000000..b0ffde0d --- /dev/null +++ b/demo/frosting/build/Tasks/TestZipTask.cs @@ -0,0 +1,27 @@ +using Cake.Common.Diagnostics; +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; + +namespace Build.Tasks +{ + [TaskName("TestZip")] + [IsDependentOn(typeof(ZipItTask))] + public sealed class TestZipTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => ArgumentArchiveBuilder.WithArchive(m + .InTestMode(), context.Output.CombineWithFilePath("archive.zip")) + .WithCommandOutput(o => + { + context.Information("7Zip version is:" + o.Information); + foreach (var archiveTestResult in o.Archives) + { + var isOk = archiveTestResult.IsOk ? "OK" : "not OK"; + context.Information($" - {archiveTestResult.FileName} test is { isOk }"); + } + })); + } + } +} diff --git a/demo/frosting/build/Tasks/UnzipItTask.cs b/demo/frosting/build/Tasks/UnzipItTask.cs new file mode 100644 index 00000000..4ab384a8 --- /dev/null +++ b/demo/frosting/build/Tasks/UnzipItTask.cs @@ -0,0 +1,24 @@ +using Cake.Common.IO; +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; +using Cake.SevenZip.Switches; + +namespace Build.Tasks +{ + [TaskName("UnzipIt")] + [IsDependentOn(typeof(ZipItTask))] + public sealed class UnzipItTask : FrostingTask + { + public override void Run(BuildContext context) + { + var d = context.Output.Combine("extracted"); + context.CleanDirectory(d); + context.SevenZip(m => m + .InExtractMode() + .WithArchive(context.Output.CombineWithFilePath("archive.zip")) + .WithOutputDirectory(d) + .WithIncludeFilenames(RecurseType.Enable, "*.cs", "*.xml")); + } + } +} diff --git a/demo/frosting/build/Tasks/UpdateItTask.cs b/demo/frosting/build/Tasks/UpdateItTask.cs new file mode 100644 index 00000000..3a6cf357 --- /dev/null +++ b/demo/frosting/build/Tasks/UpdateItTask.cs @@ -0,0 +1,18 @@ +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; + +namespace Build.Tasks +{ + [TaskName("UpdateIt")] + [IsDependentOn(typeof(ZipItTask))] + public sealed class UpdateItTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => ArgumentArchiveBuilder.WithArchive(m + .InUpdateMode(), context.Output.CombineWithFilePath("archive.zip")) + .WithFiles(context.Root.CombineWithFilePath("LICENSE.txt"))); + } + } +} diff --git a/demo/frosting/build/Tasks/ZipItTask.cs b/demo/frosting/build/Tasks/ZipItTask.cs new file mode 100644 index 00000000..511f8c38 --- /dev/null +++ b/demo/frosting/build/Tasks/ZipItTask.cs @@ -0,0 +1,19 @@ +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; + +namespace Build.Tasks +{ + [TaskName("ZipIt")] + public sealed class ZipItTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => m + .InAddMode() + .WithArchive(context.Output.CombineWithFilePath("archive.zip")) + .WithFiles(context.Root.CombineWithFilePath("README.MD")) + .WithFiles(context.Root.CombineWithFilePath("CODE_OF_CONDUCT.md"))); + } + } +} diff --git a/demo/frosting/build/Tasks/ZipVolumesTask.cs b/demo/frosting/build/Tasks/ZipVolumesTask.cs new file mode 100644 index 00000000..44ca1792 --- /dev/null +++ b/demo/frosting/build/Tasks/ZipVolumesTask.cs @@ -0,0 +1,22 @@ +using Cake.Frosting; +using Cake.SevenZip; +using Cake.SevenZip.Builder; +using Cake.SevenZip.Switches; + +namespace Build.Tasks +{ + [TaskName("ZipVolumes")] + public sealed class ZipVolumesTask : FrostingTask + { + public override void Run(BuildContext context) + { + context.SevenZip(m => m + .InAddMode() + .WithArchive(context.Output.CombineWithFilePath("volume.7z")) + .WithArchiveType(SwitchArchiveType.SevenZip) + .WithDirectoryContents(context.Root.Combine("src")) + .WithCompressFilesOpenForWriting() + .WithVolume(20, VolumeUnit.Megabytes)); + } + } +} diff --git a/recipe.cake b/recipe.cake index 3080dc57..2c56889b 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:?package=Cake.Recipe&version=2.1.0 +#load nuget:?package=Cake.Recipe&version=2.2.0 Environment.SetVariableNames(); diff --git a/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj b/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj index 8cd7f04f..24f98deb 100644 --- a/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj +++ b/src/Cake.7zip.Tests/Cake.7zip.Tests.csproj @@ -11,19 +11,19 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.7zip/Cake.7zip.csproj b/src/Cake.7zip/Cake.7zip.csproj index 2b6b87fe..5c549e5f 100644 --- a/src/Cake.7zip/Cake.7zip.csproj +++ b/src/Cake.7zip/Cake.7zip.csproj @@ -25,7 +25,7 @@ Makes 7zip available as a tool in Cake MIT https://cake-contrib.github.io/Cake.7zip - cake;addin;SevenZip;7zip + cake, build, cake-build, script, cake-addin, SevenZip, 7zip https://github.com/cake-contrib/Cake.7zip.git https://github.com/cake-contrib/Cake.7zip/releases Cake.SevenZip @@ -35,13 +35,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive