Skip to content

Commit 8366bad

Browse files
committed
(build) generate zip for windows instead of tar.gz
1 parent 3ba561d commit 8366bad

File tree

7 files changed

+65
-45
lines changed

7 files changed

+65
-45
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ jobs:
108108
-
109109
name: 'Upload native packages'
110110
uses: actions/[email protected]
111+
if: matrix.os == 'windows-latest'
112+
with:
113+
name: native-${{ runner.os }}
114+
path: ${{ github.workspace }}/artifacts/packages/native/*.zip
115+
-
116+
name: 'Upload native packages'
117+
uses: actions/[email protected]
118+
if: matrix.os != 'windows-latest'
111119
with:
112120
name: native-${{ runner.os }}
113121
path: ${{ github.workspace }}/artifacts/packages/native/*.tar.gz

build/.run/Package GZip.run.xml renamed to build/.run/Package Archive.run.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<component name="ProjectRunConfigurationManager">
2-
<configuration default="false" name="Package GZip" type="DotNetProject" factoryName=".NET Project" folderName="Package">
2+
<configuration default="false" name="Package Archive" type="DotNetProject" factoryName=".NET Project" folderName="Package">
33
<option name="EXE_PATH" value="$PROJECT_DIR$/../run/build.exe" />
4-
<option name="PROGRAM_PARAMETERS" value="--target=PackageGZip" />
4+
<option name="PROGRAM_PARAMETERS" value="--target=PackageArchive" />
55
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.." />
66
<option name="PASS_PARENT_ENVS" value="1" />
77
<option name="USE_EXTERNAL_CONSOLE" value="0" />
@@ -17,4 +17,4 @@
1717
<option name="Build" />
1818
</method>
1919
</configuration>
20-
</component>
20+
</component>

build/build/Tasks/Package.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Build.Tasks;
44
[TaskDescription("Creates the packages (nuget, chocolatey or tar.gz)")]
55
[IsDependentOn(typeof(PackageChocolatey))]
66
[IsDependentOn(typeof(PackageNuget))]
7-
[IsDependentOn(typeof(PackageGZip))]
7+
[IsDependentOn(typeof(PackageArchive))]
88
public class Package : FrostingTask<BuildContext>
99
{
1010
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Cake.Compression;
2+
using Common.Utilities;
3+
4+
namespace Build.Tasks;
5+
6+
[TaskName(nameof(PackageArchive))]
7+
[TaskDescription("Creates the tar.gz or zip packages")]
8+
[IsDependentOn(typeof(PackagePrepare))]
9+
public class PackageArchive : FrostingTask<BuildContext>
10+
{
11+
public override void Run(BuildContext context)
12+
{
13+
context.EnsureDirectoryExists(Paths.Native);
14+
15+
var platform = context.Environment.Platform.Family;
16+
var runtimes = context.NativeRuntimes[platform];
17+
18+
foreach (var runtime in runtimes)
19+
{
20+
var sourceDir = Paths.Native.Combine(platform.ToString().ToLower()).Combine(runtime);
21+
var targetDir = Paths.Native;
22+
context.EnsureDirectoryExists(targetDir);
23+
24+
var archive = GetArchiveOutputPath(context, runtime, platform, targetDir);
25+
var filePaths = context.GetFiles($"{sourceDir}/**/*");
26+
switch (platform)
27+
{
28+
case PlatformFamily.Windows:
29+
context.ZipCompress(sourceDir, archive, filePaths);
30+
break;
31+
default:
32+
context.GZipCompress(sourceDir, archive, filePaths);
33+
break;
34+
}
35+
36+
context.Information($"Created {archive}");
37+
}
38+
base.Run(context);
39+
}
40+
private static FilePath GetArchiveOutputPath(BuildContextBase context, string runtime, PlatformFamily platform, DirectoryPath targetDir)
41+
{
42+
var ext = platform == PlatformFamily.Windows ? "zip" : "tar.gz";
43+
var fileName = $"gitversion-{runtime}-{context.Version?.SemVersion}.{ext}".ToLower();
44+
return targetDir.CombineWithFilePath(fileName);
45+
}
46+
}

build/build/Tasks/Package/PackageGZip.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

build/build/Tasks/Package/PackageNuget.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ private static void PackageWithCli(BuildContext context)
2323
Configuration = context.MsBuildConfiguration,
2424
OutputDirectory = Paths.Nuget,
2525
MSBuildSettings = context.MsBuildSettings,
26-
ArgumentCustomization = arg => arg.Append("/p:PackAsTool=true")
2726
};
2827

2928
// GitVersion.MsBuild, global tool & core
30-
context.DotNetCorePack("./src/GitVersion.App/GitVersion.App.csproj", settings);
29+
context.DotNetCorePack("./src/GitVersion.Core", settings);
30+
31+
settings.ArgumentCustomization = arg => arg.Append("/p:PackAsTool=true");
32+
context.DotNetCorePack("./src/GitVersion.App", settings);
3133

3234
settings.ArgumentCustomization = arg => arg.Append("/p:IsPackaging=true");
3335
context.DotNetCorePack("./src/GitVersion.MsBuild", settings);
34-
35-
settings.ArgumentCustomization = null;
36-
context.DotNetCorePack("./src/GitVersion.Core", settings);
3736
}
3837
private static void PackageUsingNuspec(BuildContextBase context)
3938
{

build/release/Tasks/PublishRelease.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public override void Run(BuildContext context)
3333
throw new InvalidOperationException("Could not resolve GitHub Token.");
3434
}
3535

36-
var tarGzFiles = context.GetFiles(Paths.Native + "/*.tar.gz").Select(x => x.ToString()).ToList();
37-
context.Information("zip count: " + tarGzFiles.Count);
36+
var archives = context.GetFiles(Paths.Native + "/*.{tar.gz,zip}").Select(x => x.ToString()).ToList();
37+
context.Information("Archives count: " + archives.Count);
3838

39-
var assets = string.Join(",", tarGzFiles);
39+
var assets = string.Join(",", archives);
4040

4141
var milestone = context.Version?.Milestone;
4242

0 commit comments

Comments
 (0)