Skip to content

Commit 9622f33

Browse files
committed
made possible to create multiple singlefile selfcontained for a single platform
1 parent c8f0eb6 commit 9622f33

File tree

4 files changed

+54
-45
lines changed

4 files changed

+54
-45
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
matrix:
106106
os: [linux]
107107
targetFramework: [2.1, 3.1]
108-
distro: [centos-7, debian-9, fedora-30, ubuntu-16.04, ubuntu-18.04]
108+
distro: [centos.7-x64, debian.9-x64, fedora.30-x64, ubuntu.16.04-x64, ubuntu.18.04-x64]
109109
fail-fast: false
110110

111111
steps:
@@ -175,7 +175,7 @@ jobs:
175175
matrix:
176176
os: [linux]
177177
targetFramework: [2.1, 3.1]
178-
distro: [centos-7, debian-9, fedora-30, ubuntu-16.04, ubuntu-18.04]
178+
distro: [centos.7-x64, debian.9-x64, fedora.30-x64, ubuntu.16.04-x64, ubuntu.18.04-x64]
179179
fail-fast: false
180180

181181
steps:

build/pack.cake

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Task("Pack-Nuget")
8282
});
8383

8484
Task("Pack-Chocolatey")
85-
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsRunningOnWindows, "Pack-Chocolatey works only on Windows agents.")
85+
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsRunningOnWindows, "Pack-Chocolatey works only on Windows agents.")
8686
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsMainBranch && !parameters.IsPullRequest, "Pack-Chocolatey works only for main branch.")
8787
.IsDependentOn("Pack-Prepare")
8888
.Does<BuildParameters>((parameters) =>
@@ -110,43 +110,52 @@ Task("Zip-Files")
110110
.IsDependentOn("Pack-Prepare")
111111
.Does<BuildParameters>((parameters) =>
112112
{
113-
var platform = Context.Environment.Platform.Family.ToString().ToLower();
114-
115-
var sourceDir = parameters.Paths.Directories.Native.Combine(platform);
116-
var targetDir = parameters.Paths.Directories.ArtifactsRoot.Combine("native");
117-
EnsureDirectoryExists(targetDir);
118-
var fileName = $"gitversion-{platform}-{parameters.Version.SemVersion}.tar.gz".ToLower();
119-
var tarFile = targetDir.CombineWithFilePath(fileName);
120-
GZipCompress(sourceDir, tarFile);
113+
var platform = Context.Environment.Platform.Family;
114+
var runtimes = parameters.NativeRuntimes[platform];
115+
116+
foreach (var runtime in runtimes)
117+
{
118+
var sourceDir = parameters.Paths.Directories.Native.Combine(platform.ToString().ToLower()).Combine(runtime);
119+
var targetDir = parameters.Paths.Directories.ArtifactsRoot.Combine("native");
120+
EnsureDirectoryExists(targetDir);
121+
var fileName = $"gitversion-{runtime}-{parameters.Version.SemVersion}.tar.gz".ToLower();
122+
var tarFile = targetDir.CombineWithFilePath(fileName);
123+
GZipCompress(sourceDir, tarFile);
124+
}
121125
});
122126

123127
void PackPrepareNative(ICakeContext context, BuildParameters parameters)
124128
{
125129
// publish single file for all native runtimes (self contained)
126130
var platform = Context.Environment.Platform.Family;
127-
var runtime = parameters.NativeRuntimes[platform];
128-
var outputPath = parameters.Paths.Directories.Native.Combine(platform.ToString().ToLower());
131+
var runtimes = parameters.NativeRuntimes[platform];
129132

130-
var settings = new DotNetCorePublishSettings
133+
foreach (var runtime in runtimes)
131134
{
132-
Framework = parameters.CoreFxVersion31,
133-
Runtime = runtime,
134-
NoRestore = false,
135-
Configuration = parameters.Configuration,
136-
OutputDirectory = outputPath,
137-
MSBuildSettings = parameters.MSBuildSettings,
138-
};
135+
var outputPath = parameters.Paths.Directories.Native.Combine(platform.ToString().ToLower()).Combine(runtime);
139136

140-
settings.ArgumentCustomization =
141-
arg => arg
142-
.Append("/p:PublishSingleFile=true")
143-
.Append("/p:PublishTrimmed=true")
144-
.Append("/p:IncludeSymbolsInSingleFile=true");
137+
var settings = new DotNetCorePublishSettings
138+
{
139+
Framework = parameters.CoreFxVersion31,
140+
Runtime = runtime,
141+
NoRestore = false,
142+
Configuration = parameters.Configuration,
143+
OutputDirectory = outputPath,
144+
MSBuildSettings = parameters.MSBuildSettings,
145+
};
146+
147+
settings.ArgumentCustomization =
148+
arg => arg
149+
.Append("/p:PublishSingleFile=true")
150+
.Append("/p:PublishTrimmed=true")
151+
.Append("/p:IncludeSymbolsInSingleFile=true");
145152

146-
context.DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", settings);
153+
context.DotNetCorePublish("./src/GitVersionExe/GitVersionExe.csproj", settings);
147154

148-
context.Information("Validating native lib:");
155+
context.Information("Validating native lib:");
156+
157+
var nativeExe = outputPath.CombineWithFilePath(IsRunningOnWindows() ? "gitversion.exe" : "gitversion");
158+
ValidateOutput(nativeExe.FullPath, "/showvariable FullSemver", parameters.Version.GitVersion.FullSemVer);
159+
}
149160

150-
var nativeExe = outputPath.CombineWithFilePath(IsRunningOnWindows() ? "gitversion.exe" : "gitversion");
151-
ValidateOutput(nativeExe.FullPath, "/showvariable FullSemver", parameters.Version.GitVersion.FullSemVer);
152161
}

build/utils/parameters.cake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class BuildParameters
5454
public BuildArtifacts Artifacts { get; private set; }
5555
public DockerImages Docker { get; private set; }
5656
public Dictionary<string, DirectoryPath> PackagesBuildMap { get; private set; }
57-
public Dictionary<PlatformFamily, string> NativeRuntimes { get; private set; }
57+
public Dictionary<PlatformFamily, string[]> NativeRuntimes { get; private set; }
5858

5959
public bool IsStableRelease() => !IsLocalBuild && IsMainRepo && IsMainBranch && !IsPullRequest && IsTagged;
6060
public bool IsPreRelease() => !IsLocalBuild && IsMainRepo && IsMainBranch && !IsPullRequest && !IsTagged;
@@ -138,11 +138,11 @@ public class BuildParameters
138138
["GitVersion.Portable"] = Paths.Directories.ArtifactsBinPortable,
139139
};
140140

141-
NativeRuntimes = new Dictionary<PlatformFamily, string>
141+
NativeRuntimes = new Dictionary<PlatformFamily, string[]>
142142
{
143-
[PlatformFamily.Windows] = "win-x64",
144-
[PlatformFamily.Linux] = "linux-x64",
145-
[PlatformFamily.OSX] = "osx-x64",
143+
[PlatformFamily.Windows] = new[] { "win-x64", "win-x86" },
144+
[PlatformFamily.Linux] = new[] { "linux-x64" },
145+
[PlatformFamily.OSX] = new[] { "osx-x64" },
146146
};
147147

148148
Credentials = BuildCredentials.GetCredentials(context);

src/Docker/docker.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"linux": {
33
"2.1": [
4-
"centos-7",
5-
"debian-9",
6-
"fedora-30",
7-
"ubuntu-16.04",
8-
"ubuntu-18.04"
4+
"centos.7-x64",
5+
"debian.9-x64",
6+
"fedora.30-x64",
7+
"ubuntu.16.04-x64",
8+
"ubuntu.18.04-x64"
99
],
1010
"3.1": [
11-
"centos-7",
12-
"debian-9",
13-
"fedora-30",
14-
"ubuntu-16.04",
15-
"ubuntu-18.04"
11+
"centos.7-x64",
12+
"debian.9-x64",
13+
"fedora.30-x64",
14+
"ubuntu.16.04-x64",
15+
"ubuntu.18.04-x64"
1616
]
1717
},
1818
"windows": {

0 commit comments

Comments
 (0)