From 93cf6f3a35a65de56ad9848479f7e4d9b556c2f8 Mon Sep 17 00:00:00 2001 From: "harry.cpp" Date: Tue, 7 Nov 2023 20:30:16 +0100 Subject: [PATCH] Use the new buildscripts submodule --- .github/workflows/main.yml | 34 ++++++++------------------- .gitmodules | 3 +++ MonoGame.Library.SDL.sln => Build.sln | 2 -- build/Build.csproj | 14 ++++++++++- build/BuildLinuxTask.cs | 2 ++ build/BuildMacOSTask.cs | 2 ++ build/BuildWindowsTask.cs | 2 ++ build/PackageTask.cs | 24 ------------------- build/Program.cs | 19 +-------------- buildscripts | 1 + src/MonoGame.Library.SDL.csproj | 29 ----------------------- 11 files changed, 34 insertions(+), 98 deletions(-) rename MonoGame.Library.SDL.sln => Build.sln (87%) delete mode 100644 build/PackageTask.cs create mode 160000 buildscripts delete mode 100644 src/MonoGame.Library.SDL.csproj diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d918bc..62f1256 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,8 @@ jobs: matrix: os: [windows-latest, macos-latest, ubuntu-20.04] steps: + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 - name: Add msbuild to PATH if: runner.os == 'Windows' uses: microsoft/setup-msbuild@v1.0.2 @@ -31,12 +33,9 @@ jobs: submodules: recursive - name: Run CAKE run: dotnet run --project ./build/Build.csproj - - name: Package artifacts - uses: actions/upload-artifact@main - with: - name: SDL-${{ matrix.os }} - path: | - artifacts/* + env: + ACTIONS_RUNTIME_TOKEN: ${{ env.ACTIONS_RUNTIME_TOKEN }} + ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}" deploy: name: deploy runs-on: ubuntu-latest @@ -46,30 +45,17 @@ jobs: needs: [ build ] if: ${{ github.event_name == 'push' }} steps: + - name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v3 - name: Clone repository uses: actions/checkout@v4 with: submodules: recursive - - name: Download artifacts for Windows x64 - uses: actions/download-artifact@v3 - with: - name: SDL-windows-latest - path: artifacts-windows-x64 - - name: Download artifacts for macOS - uses: actions/download-artifact@v3 - with: - name: SDL-macos-latest - path: artifacts-macos - - name: Download artifacts for Linux x64 - uses: actions/download-artifact@v3 - with: - name: SDL-ubuntu-20.04 - path: artifacts-linux-x64 - name: Run CAKE - run: dotnet run --project ./build/Build.csproj -- "--target=Package" - - name: Push packages - run: dotnet nuget push src/bin/Release/*.nupkg --source https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --api-key ${GITHUB_TOKEN} + run: dotnet run --project ./build/Build.csproj -- --target=Package --libraryname=FreeImage --licensepath=freeimage/license-fi.txt env: + ACTIONS_RUNTIME_TOKEN: ${{ env.ACTIONS_RUNTIME_TOKEN }} + ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Make a release uses: ncipollo/release-action@v1 diff --git a/.gitmodules b/.gitmodules index 2c188a9..4117ede 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "sdl"] path = sdl url = https://github.com/libsdl-org/SDL.git +[submodule "buildscripts"] + path = buildscripts + url = https://github.com/MonoGame/MonoGame.Library.BuildScripts.git diff --git a/MonoGame.Library.SDL.sln b/Build.sln similarity index 87% rename from MonoGame.Library.SDL.sln rename to Build.sln index c48dc40..eb83df1 100644 --- a/MonoGame.Library.SDL.sln +++ b/Build.sln @@ -3,8 +3,6 @@ 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}") = "MonoGame.Library.SDL", "src\MonoGame.Library.SDL.csproj", "{F9BD9E87-2B0B-4CB8-9C39-3FACD66E14AF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "build\Build.csproj", "{8363325E-56EB-4B87-B170-C28237FB80CC}" EndProject Global diff --git a/build/Build.csproj b/build/Build.csproj index 77721f3..d3c7db5 100644 --- a/build/Build.csproj +++ b/build/Build.csproj @@ -1,12 +1,18 @@ + Exe net7.0 $(MSBuildProjectDirectory) enable + enable + true + + + @@ -17,8 +23,14 @@ + - \ No newline at end of file + + + + + + diff --git a/build/BuildLinuxTask.cs b/build/BuildLinuxTask.cs index c655498..08881e7 100644 --- a/build/BuildLinuxTask.cs +++ b/build/BuildLinuxTask.cs @@ -2,6 +2,8 @@ namespace BuildScripts; [TaskName("Build Linux")] +[IsDependentOn(typeof(PrepTask))] +[IsDependeeOf(typeof(BuildLibraryTask))] public sealed class BuildLinuxTask : FrostingTask { public override bool ShouldRun(BuildContext context) => context.IsRunningOnLinux(); diff --git a/build/BuildMacOSTask.cs b/build/BuildMacOSTask.cs index e75f4f6..7f36581 100644 --- a/build/BuildMacOSTask.cs +++ b/build/BuildMacOSTask.cs @@ -2,6 +2,8 @@ namespace BuildScripts; [TaskName("Build macOS")] +[IsDependentOn(typeof(PrepTask))] +[IsDependeeOf(typeof(BuildLibraryTask))] public sealed class BuildMacOSTask : FrostingTask { public override bool ShouldRun(BuildContext context) => context.IsRunningOnMacOs(); diff --git a/build/BuildWindowsTask.cs b/build/BuildWindowsTask.cs index a44959f..ff1879b 100644 --- a/build/BuildWindowsTask.cs +++ b/build/BuildWindowsTask.cs @@ -2,6 +2,8 @@ namespace BuildScripts; [TaskName("Build Windows")] +[IsDependentOn(typeof(PrepTask))] +[IsDependeeOf(typeof(BuildLibraryTask))] public sealed class BuildWindowsTask : FrostingTask { public override bool ShouldRun(BuildContext context) => context.IsRunningOnWindows(); diff --git a/build/PackageTask.cs b/build/PackageTask.cs deleted file mode 100644 index 9c6e0ab..0000000 --- a/build/PackageTask.cs +++ /dev/null @@ -1,24 +0,0 @@ - -namespace BuildScripts; - -[TaskName("Package")] -public sealed class PackageTask : FrostingTask -{ - public override void Run(BuildContext context) - { - var sdlMajor = context.FindRegexMatchGroupInFile("sdl/include/SDL_version.h", @"#define SDL_MAJOR_VERSION +(?\d+)", 1, System.Text.RegularExpressions.RegexOptions.Singleline); - var sdlMinor = context.FindRegexMatchGroupInFile("sdl/include/SDL_version.h", @"#define SDL_MINOR_VERSION +(?\d+)", 1, System.Text.RegularExpressions.RegexOptions.Singleline); - var sdlPatch = context.FindRegexMatchGroupInFile("sdl/include/SDL_version.h", @"#define SDL_PATCHLEVEL +(?\d+)", 1, System.Text.RegularExpressions.RegexOptions.Singleline); - var sdlVersion = $"{sdlMajor}.{sdlMinor}.{sdlPatch}"; - var dnMsBuildSettings = new DotNetMSBuildSettings(); - dnMsBuildSettings.WithProperty("Version", sdlVersion + "." + context.EnvironmentVariable("GITHUB_RUN_NUMBER")); - dnMsBuildSettings.WithProperty("RepositoryUrl", "https://github.com/" + context.EnvironmentVariable("GITHUB_REPOSITORY")); - - context.DotNetPack("src/MonoGame.Library.SDL.csproj", new DotNetPackSettings - { - MSBuildSettings = dnMsBuildSettings, - Verbosity = DotNetVerbosity.Minimal, - Configuration = "Release" - }); - } -} diff --git a/build/Program.cs b/build/Program.cs index 6b61b55..395b6b0 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -5,25 +5,8 @@ public static class Program { public static int Main(string[] args) => new CakeHost() + .AddAssembly(typeof(BuildContext).Assembly) .UseWorkingDirectory("../") .UseContext() .Run(args); } - -public class BuildContext : FrostingContext -{ - public string ArtifactsDir { get; } - - public BuildContext(ICakeContext context) : base(context) - { - ArtifactsDir = context.Arguments("artifactsDir", "artifacts").FirstOrDefault(); - } -} - -[TaskName("Default")] -[IsDependentOn(typeof(BuildWindowsTask))] -[IsDependentOn(typeof(BuildMacOSTask))] -[IsDependentOn(typeof(BuildLinuxTask))] -public class DefaultTask : FrostingTask -{ -} diff --git a/buildscripts b/buildscripts new file mode 160000 index 0000000..150661e --- /dev/null +++ b/buildscripts @@ -0,0 +1 @@ +Subproject commit 150661e440da9fb46ce82447a11df4c2a05c610f diff --git a/src/MonoGame.Library.SDL.csproj b/src/MonoGame.Library.SDL.csproj deleted file mode 100644 index d8b0dac..0000000 --- a/src/MonoGame.Library.SDL.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - - netstandard2.0 - NU5128 - MonoGame build of SDL Library - This package contains an SDL library built for distributing MonoGame games. - false - LICENSE.txt - - - - - - - SDL2.dll - runtimes\win-x64\native - - - libSDL2-2.0.0.dylib - runtimes\osx\native - - - libSDL2-2.0.so.0 - runtimes\linux-x64\native - - - -