Drop CAKE build and move Build CI to github workflow

This commit is contained in:
Christopher Whitley
2024-05-19 15:28:33 -04:00
parent 6b02975755
commit 24d9477a0f
17 changed files with 183 additions and 351 deletions
-49
View File
@@ -1,49 +0,0 @@
name: "Build test deploy"
on:
push:
branches: [develop, test/feature]
tags: [v*]
pull_request:
branches: [develop]
pull_request_target:
branches: [develop]
jobs:
build-test-pack-job:
name: "Build-Test-Pack"
runs-on: ubuntu-latest
steps:
- name: "Clone Repository"
uses: actions/checkout@v4
- name: "CAKE (Build -> Test -> Package)"
run: dotnet run --project ./src/cs/Build/Build.csproj -- --target=Default
- name: "Upload Artifacts For Deploy"
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@main
with:
name: MonoGame.Extended
path: artifacts/*
deploy-job:
name: "Deploy Nugets"
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
needs: [build-test-pack-job]
if: ${{ github.event_name == 'push' }}
steps:
- name: "Clone Repository"
uses: actions/checkout@v4
- name: "Download Artifacts For Deploy"
uses: actions/download-artifact@main
with:
name: MonoGame.Extended
path: artifacts
- name: "Push Package"
run: dotnet run --project ./build/Build.csproj -- --target=Deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MYGET_ACCESS_TOKEN: ${{ secrets.MYGET_ACCESS_TOKEN }}
NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }}
+75
View File
@@ -0,0 +1,75 @@
################################################################################
### Build MonoGame.Extended (Develop)
### Clones the `develop` branch and performs a build, test, then pack of the
### Monogame.Extended source code. Once the build job is finished, the deploy
### job will upload the nupkg files created to the MonoGame.Extended GitHub
### and NuGet sources.
###
### - Only runs on a push to the `develop` branch
### - Sets the IS_PRERELASE and BUILD_NUMBER environment variables which are
### picked up in the Directory.Build.props file to set the version suffix
### so the packages are build as prerelease packages.
################################################################################
name: "Build MonoGame.Extended (Develop)"
on:
push:
branches: develop
jobs:
build:
name: "Build MonoGame.Extended"
runs-on: ubuntu-latest
env:
IS_PRERELEASE: true
BUILD_NUMBER: ${{ github.run_id }}
steps:
- name: Clone Repository
uses: actions/checkout@v4
with:
ref: develop
- name: Setup DotNet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Test MonoGame.Extended
run: dotnet test --nologo --verbosity minimial --configuration Release
- name: Build MonoGame.Extended
run: dotnet build --nologo --verbosity minimal --configuration Release
- name: Pack MonoGame.Extended
run: dotnet pack --nologo --verbosity minimal --configuration Release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: ./.artifacts/source/package/release/*.nupkg
deploy-job:
name: "Deploy Nugets"
runs-on: ubuntu-latest
needs: [build]
permissions:
packages: write
contents: write
steps:
- name: "Download Artifacts For Deploy"
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./.artifacts
- name: "Push Packages"
run: |
PACKAGES=(".artifacts/*.nupkg")
for PACKAGE in "${PACKAGES[@]}"; do
dotnet nuget push "$PACKAGE" --source "github" --skip-duplicate --api-key "${{ env.GITHUB_TOKEN }}"
dotnet nuget push "$PACKAGE" --source "https://api.nuget.org/v3/index.json" --skip-duplicate --api-key "${{ secrets.NUGET_ACCESS_TOKEN }}"
done
+32
View File
@@ -0,0 +1,32 @@
################################################################################
### Pull Request Test
### Executes tests to ensure that the pull request being submitted is valid.
### - Only runs on pull requests made to the `develop` branch
### - Only runs if the pull request was opened or synchronized
################################################################################
name: Pull Request Test
on:
pull_request:
branches:
- develop
- main
types:
- opened
- synchronize
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v4
- name: Setup DotNet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Test MonoGame.Extended
run: dotnet test --nologo --verbosity minimial --configuration Release
+70
View File
@@ -0,0 +1,70 @@
################################################################################
### Build MonoGame.Extended (Release)
### Clones the `main` branch and performs a build, test, then pack of the
### Monogame.Extended source code. Once the build job is finished, the deploy
### job will upload the nupkg files created to the MonoGame.Extended NuGet
### source.
###
### - Only runs when there is a new version release tag created.
################################################################################
name: "Build MonoGame.Extended (Release)"
on:
push:
tags:
- 'v*'
jobs:
build:
name: "Build MonoGame.Extended"
runs-on: ubuntu-latest
steps:
- name: Clone Repository
uses: actions/checkout@v4
with:
ref: main
- name: Setup DotNet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Test MonoGame.Extended
run: dotnet test --nologo --verbosity minimial --configuration Release
- name: Build MonoGame.Extended
run: dotnet build --nologo --verbosity minimal --configuration Release
- name: Pack MonoGame.Extended
run: dotnet pack --nologo --verbosity minimal --configuration Release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: ./.artifacts/source/package/release/*.nupkg
deploy-job:
name: "Deploy Nugets"
runs-on: ubuntu-latest
needs: [build]
permissions:
packages: write
contents: write
steps:
- name: "Download Artifacts For Deploy"
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./.artifacts
- name: "Push Packages"
run: |
PACKAGES=(".artifacts/*.nupkg")
for PACKAGE in "${PACKAGES[@]}"; do
dotnet nuget push "$PACKAGE" --source "github" --skip-duplicate --api-key "${{ env.GITHUB_TOKEN }}"
dotnet nuget push "$PACKAGE" --source "https://api.nuget.org/v3/index.json" --skip-duplicate --api-key "${{ secrets.NUGET_ACCESS_TOKEN }}"
done
+6 -1
View File
@@ -5,10 +5,15 @@
<TargetFramework>net6.0</TargetFramework>
<SolutionDirectory>$(MSBuildThisFileDirectory)</SolutionDirectory>
</PropertyGroup>
<PropertyGroup>
<MonoGameExtendedVersion>3.9.0</MonoGameExtendedVersion>
<IsPrerelease Condition="'$(IS_PRERELEASE)' != ''">-prerelease</IsPrerelease>
<BuildNumber Condition="'$(BUILD_NUMBER)' != ''">.$(BUILD_NUMBER)</BuildNumber>
<Version>$(MonoGameExtendedVersion)$(IsPrerelease)$(BuildNumber)</Version>
</PropertyGroup>
<PropertyGroup>
<Version>3.9.0</Version>
<Authors>craftworkgames and contributors</Authors>
<PackageProjectUrl>https://github.com/craftworkgames/MonoGame.Extended</PackageProjectUrl>
<RepositoryUrl>https://github.com/craftworkgames/MonoGame.Extended</RepositoryUrl>
-13
View File
@@ -44,10 +44,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Tiled.Tes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Tweening.Tests", "tests\MonoGame.Extended.Tweening.Tests\MonoGame.Extended.Tweening.Tests.csproj", "{C2A9982B-7BF7-4243-9E05-CFD31752B6DC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{D596CBD4-8DDE-46BD-AF76-59FC1F03BF64}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "build\Build.csproj", "{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -208,14 +204,6 @@ Global
{C2A9982B-7BF7-4243-9E05-CFD31752B6DC}.Release|Any CPU.Build.0 = Release|Any CPU
{C2A9982B-7BF7-4243-9E05-CFD31752B6DC}.Release|x86.ActiveCfg = Release|Any CPU
{C2A9982B-7BF7-4243-9E05-CFD31752B6DC}.Release|x86.Build.0 = Release|Any CPU
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}.Debug|x86.ActiveCfg = Debug|Any CPU
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}.Debug|x86.Build.0 = Debug|Any CPU
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}.Release|Any CPU.Build.0 = Release|Any CPU
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}.Release|x86.ActiveCfg = Release|Any CPU
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -240,7 +228,6 @@ Global
{E1339B07-EB0B-454F-9803-E923843DB5C4} = {61C82014-E3A9-4AB3-8705-FBBD5F799BA6}
{BF0EC593-4BAB-424F-B7E9-BB13EC78A0E5} = {61C82014-E3A9-4AB3-8705-FBBD5F799BA6}
{C2A9982B-7BF7-4243-9E05-CFD31752B6DC} = {61C82014-E3A9-4AB3-8705-FBBD5F799BA6}
{0D198ABB-0BA6-4AC7-8F30-E49C70AF203A} = {D596CBD4-8DDE-46BD-AF76-59FC1F03BF64}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8ED5A62D-25EC-4331-9F99-BDD1E10C02A0}
-15
View File
@@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.Frosting"
Version="3.1.0" />
</ItemGroup>
</Project>
-41
View File
@@ -1,41 +0,0 @@
using System.Linq;
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 string ArtifactsDirectory { get; }
public string Version { get; }
public string SolutionPath { get; }
public string? RepositoryOwner { get; }
public string? RepositoryUrl { get; }
public bool IsTag { get; }
public bool IsRunningOnGitHubActions { get; }
public string? GitHubToken { get; }
public string? MyGetAccessToken { get; }
public string? NuGetAccessToken { get; }
public BuildContext(ICakeContext context) : base(context)
{
ArtifactsDirectory = context.Argument(nameof(ArtifactsDirectory), ".artifacts");
Version = context.XmlPeek("Directory.Build.props", "/Project/PropertyGroup/Version");
SolutionPath = "./MonoGame.Extended.sln";
IsRunningOnGitHubActions = context.BuildSystem().IsRunningOnGitHubActions;
if (IsRunningOnGitHubActions)
{
Version += "." + context.EnvironmentVariable("GITHUB_RUN_NUMBER");
RepositoryOwner = context.EnvironmentVariable("GITHUB_REPOSITORY_OWNER");
RepositoryUrl = $"https://github.com/{context.EnvironmentVariable("GITHUB_REPOSITORY")}";
IsTag = context.EnvironmentVariable("GITHUB_REF_TYPE") == "tag";
GitHubToken = context.EnvironmentVariable("GITHUB_TOKEN");
MyGetAccessToken = context.EnvironmentVariable("MYGET_ACCESS_TOKEN");
NuGetAccessToken = context.EnvironmentVariable("NUGET_ACCESS_TOKEN");
}
}
}
-29
View File
@@ -1,29 +0,0 @@
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);
msBuildSettings.WithProperty("NoWarn", "CS1591");
DotNetBuildSettings buildSettings = new DotNetBuildSettings()
{
MSBuildSettings = msBuildSettings,
Configuration = "Release",
Verbosity = DotNetVerbosity.Minimal,
NoRestore = true,
NoLogo = true
};
context.DotNetBuild(context.SolutionPath, buildSettings);
}
}
-25
View File
@@ -1,25 +0,0 @@
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)
{
return 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("artifacts/*.nupkg", pushSettings);
}
}
-25
View File
@@ -1,25 +0,0 @@
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.NuGet.Push;
using Cake.Frosting;
namespace BuildScripts;
[TaskName(nameof(DeployToMyGetTask))]
public sealed class DeployToMyGetTask : FrostingTask<BuildContext>
{
public override bool ShouldRun(BuildContext context)
{
return context.IsRunningOnGitHubActions;
}
public override void Run(BuildContext context)
{
DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings()
{
Source = $"https://www.myget.org/F/lithiumtoast/api/v3/index.json",
ApiKey = context.MyGetAccessToken
};
context.DotNetNuGetPush("artifacts/*.nupkg", pushSettings);
}
}
-27
View File
@@ -1,27 +0,0 @@
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)
{
return context.IsRunningOnGitHubActions &&
context.IsTag &&
context.RepositoryOwner == "craftworksgames";
}
public override void Run(BuildContext context)
{
DotNetNuGetPushSettings pushSettings = new DotNetNuGetPushSettings()
{
Source = $"https://api.nuget.org/v3/index.json",
ApiKey = context.NuGetAccessToken
};
context.DotNetNuGetPush("artifacts/*.nupkg", pushSettings);
}
}
-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<ProjectCategory>build</ProjectCategory>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
</PropertyGroup>
<!-- Import the root prop last -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
</Project>
-40
View File
@@ -1,40 +0,0 @@
using Cake.Common.Build;
using Cake.Common.IO;
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.MSBuild;
using Cake.Common.Tools.DotNet.Pack;
using Cake.Core.IO;
using Cake.Frosting;
namespace BuildScripts;
[TaskName(nameof(PackageTask))]
public sealed class PackageTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
context.CleanDirectories(context.ArtifactsDirectory);
context.CreateDirectory(context.ArtifactsDirectory);
DotNetMSBuildSettings msBuildSettings = new DotNetMSBuildSettings();
msBuildSettings.WithProperty("Version", context.Version);
// Ignore warnings about adding duplicate items added to package
msBuildSettings.WithProperty("NoWarn", "NU5118");
DotNetPackSettings packSettings = new DotNetPackSettings()
{
MSBuildSettings = msBuildSettings,
Configuration = "Release",
Verbosity = DotNetVerbosity.Minimal,
NoLogo = true,
OutputDirectory = context.ArtifactsDirectory,
};
FilePathCollection files = context.GetFiles("./src/cs/MonoGame.Extended*/**/*.csproj");
foreach(FilePath file in files)
{
context.DotNetPack(file.FullPath, packSettings);
}
}
}
-33
View File
@@ -1,33 +0,0 @@
using System.Threading.Tasks;
using Cake.Common.Build;
using Cake.Common.IO;
using Cake.Common.Tools.ReportUnit;
using Cake.Core;
using Cake.Core.IO;
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 {}
-18
View File
@@ -1,18 +0,0 @@
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.Restore;
using Cake.Frosting;
namespace BuildScripts;
public sealed class RestoreTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
DotNetRestoreSettings restoreSettings = new DotNetRestoreSettings()
{
Verbosity = DotNetVerbosity.Quiet
};
context.DotNetRestore(context.SolutionPath, restoreSettings);
}
}
-22
View File
@@ -1,22 +0,0 @@
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.Test;
using Cake.Frosting;
namespace BuildScripts;
[TaskName(nameof(TestTask))]
public class TestTask : FrostingTask<BuildContext>
{
public override void Run(BuildContext context)
{
DotNetTestSettings testSettings = new DotNetTestSettings()
{
Configuration = "Release",
Verbosity = DotNetVerbosity.Normal,
NoLogo = true,
NoBuild = true
};
context.DotNetTest(context.SolutionPath, testSettings);
}
}