-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update build pipeline to include tar.gz artefacts (#374)
* Output tar.gz for non windows platform * Rename sha256 output file to match the full name of the target * Always create zip for all platforms --------- Co-authored-by: fluxzy-ci <[email protected]>
- Loading branch information
Showing
3 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2021 - Haga Rakotoharivelo - https://github.com/haga-rak | ||
|
||
using System.Formats.Tar; | ||
using System.IO.Compression; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Fluxzy.Build | ||
{ | ||
public static class CompressionHelper | ||
{ | ||
internal static void CreateZip(string inputDirectory, string outputFile) | ||
{ | ||
// add extension if missing | ||
|
||
if (!outputFile.EndsWith(".zip")) | ||
{ | ||
outputFile += ".zip"; | ||
} | ||
|
||
ZipFile.CreateFromDirectory(inputDirectory, outputFile, CompressionLevel.Optimal, | ||
includeBaseDirectory:false); | ||
} | ||
|
||
public static void CreateCompressed(string inputDirectory, string outputFile) | ||
{ | ||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
CreateTarGz(inputDirectory, outputFile); | ||
} | ||
|
||
CreateZip(inputDirectory, outputFile); | ||
} | ||
|
||
internal static void CreateTarGz(string inputDirectory, string outputFile) | ||
{ | ||
if (!outputFile.EndsWith(".tar.gz")) | ||
{ | ||
outputFile += ".tar.gz"; | ||
} | ||
|
||
using FileStream fs = new(outputFile, FileMode.CreateNew, FileAccess.Write); | ||
using GZipStream gz = new(fs, CompressionMode.Compress, leaveOpen: true); | ||
|
||
TarFile.CreateFromDirectory(inputDirectory, gz, includeBaseDirectory: false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters