Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcoltheart committed Feb 17, 2021
1 parent 5f1b603 commit adf37f1
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 422 deletions.
2 changes: 0 additions & 2 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
next-version: 1.0.0
mode: ContinuousDelivery
commit-message-incrementing: Disabled
legacy-semver-padding: 0
4 changes: 0 additions & 4 deletions build.cmd

This file was deleted.

106 changes: 50 additions & 56 deletions build/build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,62 @@
using static Bullseye.Targets;
using static SimpleExec.Command;

public class build
var version = GetGitVersion();

Target("clean", () =>
{
public static void Main(string[] args)
Run("dotnet", "clean");
if (Directory.Exists("artifacts"))
{
var version = GetGitVersion();

Target("clean", () =>
{
Run("dotnet", "clean");
if (Directory.Exists("artifacts"))
{
Directory.Delete("artifacts", true);
}
});

Target("restore", DependsOn("clean"), () =>
{
Run("dotnet", "restore");
});

Target("build", DependsOn("restore"), () =>
{
Run("dotnet", "build " +
"--no-restore " +
"--configuration Release " +
$"/p:Version={version.SemVer} " +
$"/p:AssemblyVersion={version.AssemblySemVer} " +
$"/p:FileVersion={version.AssemblySemFileVer} " +
$"/p:InformationalVersion={version.InformationalVersion}");
});

Target("test", DependsOn("build"), () =>
{
Run("dotnet", "test --configuration Release --no-restore --no-build");
});

Target("package", DependsOn("build", "test"), () =>
{
Run("dotnet", $"pack --configuration Release --no-restore --no-build --output artifacts /p:Version={version.SemVer}");
});

Target("publish", DependsOn("package"), () =>
{
var apiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY");
Run("dotnet", $"nuget push {Path.Combine("artifacts", "*.nupkg")} --api-key {apiKey} --source https://api.nuget.org/v3/index.json");
});

Target("default", DependsOn("package"));

RunTargetsAndExit(args);
Directory.Delete("artifacts", true);
}
});

private static GitVersion GetGitVersion()
{
Run("dotnet", "tool restore");
Target("restore", DependsOn("clean"), () =>
{
Run("dotnet", "restore");
});

var value = Read("dotnet", "dotnet-gitversion");
Target("build", DependsOn("restore"), () =>
{
Run("dotnet", "build " +
"--no-restore " +
"--configuration Release " +
$"/p:Version={version.SemVer} " +
$"/p:AssemblyVersion={version.AssemblySemVer} " +
$"/p:FileVersion={version.AssemblySemFileVer} " +
$"/p:InformationalVersion={version.InformationalVersion}");
});

Target("test", DependsOn("build"), () =>
{
Run("dotnet", "test --configuration Release --no-restore --no-build");
});

return JsonSerializer.Deserialize<GitVersion>(value);
}
Target("package", DependsOn("build", "test"), () =>
{
Run("dotnet", $"pack --configuration Release --no-restore --no-build --output artifacts /p:Version={version.SemVer}");
});

Target("publish", DependsOn("package"), () =>
{
var apiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY");
Run("dotnet", $"nuget push {Path.Combine("artifacts", "*.nupkg")} --api-key {apiKey} --source https://api.nuget.org/v3/index.json");
});

Target("default", DependsOn("package"));

RunTargetsAndExit(args);

GitVersion GetGitVersion()
{
Run("dotnet", "tool restore");

var value = Read("dotnet", "dotnet-gitversion");

return JsonSerializer.Deserialize<GitVersion>(value);
}

public class GitVersion
Expand Down
8 changes: 4 additions & 4 deletions build/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net50</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bullseye" Version="3.4.0" />
<PackageReference Include="SimpleExec" Version="6.2.0" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<PackageReference Include="Bullseye" Version="3.7.0" />
<PackageReference Include="SimpleExec" Version="6.4.0" />
<PackageReference Include="System.Text.Json" Version="5.0.1" />
</ItemGroup>

</Project>
63 changes: 0 additions & 63 deletions src/Prefab/templates/prefab/.gitattributes

This file was deleted.

Loading

0 comments on commit adf37f1

Please sign in to comment.