-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07d57fd
commit 4137bfa
Showing
13 changed files
with
256 additions
and
438 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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Cake.Frosting" Version="3.1.0" /> | ||
</ItemGroup> | ||
</Project> |
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,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "Build.csproj", "{86E7FFCA-81BE-403B-A2EE-61D4C8526111}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{86E7FFCA-81BE-403B-A2EE-61D4C8526111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{86E7FFCA-81BE-403B-A2EE-61D4C8526111}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{86E7FFCA-81BE-403B-A2EE-61D4C8526111}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{86E7FFCA-81BE-403B-A2EE-61D4C8526111}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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,48 @@ | ||
using System.IO; | ||
using Cake.Common; | ||
using Cake.Common.Build; | ||
using Cake.Common.Xml; | ||
using Cake.Core; | ||
using Cake.Frosting; | ||
|
||
namespace BuildScripts; | ||
|
||
public sealed class BuildContext : FrostingContext | ||
{ | ||
public readonly string ArtifactsDirectory; | ||
public readonly string Version; | ||
public readonly string? RepositoryOwner; | ||
public readonly string? RepositoryUrl; | ||
public readonly bool IsTag; | ||
public readonly bool IsRunningOnGitHubActions; | ||
public readonly string? GitHubToken; | ||
public readonly string? NuGetAccessToken; | ||
public readonly string MonoGameAsepritePath; | ||
public readonly string MonoGameAsepriteContentPipelinePath; | ||
public readonly string MonoGameAsepriteTestsPath; | ||
|
||
public BuildContext(ICakeContext context) : base(context) | ||
{ | ||
ArtifactsDirectory = context.Argument(nameof(ArtifactsDirectory), ".artifacts"); | ||
MonoGameAsepritePath = context.Argument(nameof(MonoGameAsepritePath), "source/MonoGame.Aseprite/MonoGame.Aseprite.csproj"); | ||
MonoGameAsepriteContentPipelinePath = context.Argument(nameof(MonoGameAsepriteContentPipelinePath), "source/MonoGame.Aseprite.Content.Pipeline/MonoGame.Aseprite.Content.Pipeline.csproj"); | ||
MonoGameAsepriteTestsPath = context.Argument(nameof(MonoGameAsepriteTestsPath), "tests/MonoGame.Aseprite.Tests/MonoGame.Aseprite.Tests.csproj"); | ||
Version = context.XmlPeek("source/MonoGame.Aseprite/MonoGame.Aseprite.csproj", "/Project/PropertyGroup/Version"); | ||
|
||
IsRunningOnGitHubActions = context.BuildSystem().IsRunningOnGitHubActions; | ||
if (IsRunningOnGitHubActions) | ||
{ | ||
RepositoryOwner = context.EnvironmentVariable("GITHUB_REPOSITORY_OWNER"); | ||
RepositoryUrl = $"https://github.com/{context.EnvironmentVariable("GITHUB_REPOSITORY")}"; | ||
GitHubToken = context.EnvironmentVariable("GITHUB_TOKEN"); | ||
IsTag = context.EnvironmentVariable("GITHUB_REF_TYPE") == "tag"; | ||
|
||
if (IsTag) | ||
{ | ||
NuGetAccessToken = context.EnvironmentVariable("NUGET_ACCESS_TOKEN"); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
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,28 @@ | ||
using Cake.Common.Tools.DotNet; | ||
using Cake.Common.Tools.DotNet.Build; | ||
using Cake.Common.Tools.DotNet.MSBuild; | ||
using Cake.Frosting; | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName(nameof(BuildTask))] | ||
public sealed class BuildTask : FrostingTask<BuildContext> | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings(); | ||
msBuildSettings.WithProperty("Version", context.Version); | ||
|
||
DotNetBuildSettings buildSettings = new DotNetBuildSettings() | ||
{ | ||
MSBuildSettings = msBuildSettings, | ||
Configuration = "Release", | ||
Verbosity = DotNetVerbosity.Minimal, | ||
NoLogo = true | ||
}; | ||
|
||
context.DotNetBuild(context.MonoGameAsepritePath, buildSettings); | ||
context.DotNetBuild(context.MonoGameAsepriteContentPipelinePath, buildSettings); | ||
context.DotNetBuild(context.MonoGameAsepriteTestsPath, buildSettings); | ||
} | ||
} |
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,22 @@ | ||
using Cake.Common.Tools.DotNet; | ||
using Cake.Common.Tools.DotNet.NuGet.Push; | ||
using Cake.Frosting; | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName(nameof(DeployToGitHubTask))] | ||
public sealed class DeployToGitHubTask : FrostingTask<BuildContext> | ||
{ | ||
public override bool ShouldRun(BuildContext context) => context.IsRunningOnGitHubActions; | ||
|
||
public override void Run(BuildContext context) | ||
{ | ||
DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings() | ||
{ | ||
Source = $"https://nuget.pkg.github.com/{context.RepositoryOwner}/index.json", | ||
ApiKey = context.GitHubToken | ||
}; | ||
|
||
context.DotNetNuGetPush($"{context.ArtifactsDirectory}/*.nupkg", pushSettings); | ||
} | ||
} |
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,28 @@ | ||
using System; | ||
using Cake.Common.Tools.DotNet; | ||
using Cake.Common.Tools.DotNet.NuGet.Push; | ||
using Cake.Frosting; | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName(nameof(DeployToNuGetTask))] | ||
public sealed class DeployToNuGetTask : FrostingTask<BuildContext> | ||
{ | ||
public override bool ShouldRun(BuildContext context) => | ||
context.IsRunningOnGitHubActions && | ||
context.IsTag && | ||
!string.IsNullOrEmpty(context.RepositoryOwner) && | ||
context.RepositoryOwner.Equals("AristurtleDev", StringComparison.InvariantCultureIgnoreCase); | ||
|
||
|
||
public override void Run(BuildContext context) | ||
{ | ||
DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings() | ||
{ | ||
Source = "https://api.nuget.org/v3/index.json", | ||
ApiKey = context.NuGetAccessToken | ||
}; | ||
|
||
context.DotNetNuGetPush($"{context.ArtifactsDirectory}/*.nupkg", pushSettings); | ||
} | ||
} |
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,30 @@ | ||
using Cake.Common.IO; | ||
using Cake.Common.Tools.DotNet; | ||
using Cake.Common.Tools.DotNet.MSBuild; | ||
using Cake.Common.Tools.DotNet.Pack; | ||
using Cake.Frosting; | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName(nameof(PackageTask))] | ||
public sealed class PackageTask : FrostingTask<BuildContext> | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
context.CleanDirectory(context.ArtifactsDirectory); | ||
context.CreateDirectory(context.ArtifactsDirectory); | ||
|
||
DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings(); | ||
msBuildSettings.WithProperty("Version", context.Version); | ||
msBuildSettings.WithProperty("PackageVersion", context.Version); | ||
|
||
DotNetPackSettings packSettings = new DotNetPackSettings() | ||
{ | ||
Configuration = "Release", | ||
OutputDirectory = context.ArtifactsDirectory, | ||
MSBuildSettings = msBuildSettings | ||
}; | ||
|
||
context.DotNetPack(context.MonoGameAsepritePath, packSettings); | ||
} | ||
} |
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,29 @@ | ||
using System.Threading.Tasks; | ||
using Cake.Core; | ||
using Cake.Core.Diagnostics; | ||
using Cake.Frosting; | ||
|
||
namespace BuildScripts; | ||
|
||
public static class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
return new CakeHost() | ||
.UseContext<BuildContext>() | ||
.UseWorkingDirectory("../") | ||
.Run(args); | ||
} | ||
} | ||
|
||
[TaskName("Default")] | ||
[IsDependentOn(typeof(RestoreTask))] | ||
[IsDependentOn(typeof(BuildTask))] | ||
[IsDependentOn(typeof(TestTask))] | ||
[IsDependentOn(typeof(PackageTask))] | ||
public sealed class DefaultTask : FrostingTask {} | ||
|
||
[TaskName("Deploy")] | ||
[IsDependentOn(typeof(DeployToGitHubTask))] | ||
[IsDependentOn(typeof(DeployToNuGetTask))] | ||
public sealed class DeployTask : FrostingTask {} |
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,20 @@ | ||
using Cake.Common.Tools.DotNet; | ||
using Cake.Common.Tools.DotNet.Restore; | ||
using Cake.Frosting; | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName(nameof(RestoreTask))] | ||
public sealed class RestoreTask : FrostingTask<BuildContext> | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
DotNetRestoreSettings restoreSettings = new DotNetRestoreSettings() | ||
{ | ||
Verbosity = DotNetVerbosity.Quiet | ||
}; | ||
context.DotNetRestore(context.MonoGameAsepritePath, restoreSettings); | ||
context.DotNetRestore(context.MonoGameAsepriteContentPipelinePath, restoreSettings); | ||
context.DotNetRestore(context.MonoGameAsepriteTestsPath, restoreSettings); | ||
} | ||
} |
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,18 @@ | ||
using Cake.Common.Tools.DotNet; | ||
using Cake.Common.Tools.DotNet.Test; | ||
using Cake.Frosting; | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName(nameof(TestTask))] | ||
public sealed class TestTask : FrostingTask<BuildContext> | ||
{ | ||
public override void Run(BuildContext context) | ||
{ | ||
DotNetTestSettings testSettings = new DotNetTestSettings() | ||
{ | ||
Configuration = "Release", | ||
}; | ||
context.DotNetTest(context.MonoGameAsepriteTestsPath, testSettings); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.