Skip to content

Commit

Permalink
Develop (#95)
Browse files Browse the repository at this point in the history
* Feature/cake frosting (#92)

* Added games list

Add list of games made with MonoGame.Aseprite

* Always specify generate documentation file

* Switch to Cake Frosting

* Update workflow script

* Issue/try get slice 92 (#94)

* Added MonoGame.Aseprite to Test .sln
This is so intellesense would pickup correct

* Added test for issue #92

* Use `_slices` and not `_tags`
The `AsepriteSlice.TryGetSlice(string, out AsepriteSlice?)` method incorrectly searched the `_tags` array and not the `_slices` array.  This resolves issue #92

* Bump version number

* Update release notes
  • Loading branch information
AristurtleDev authored Dec 2, 2023
1 parent 8d92eeb commit ce5f41a
Show file tree
Hide file tree
Showing 22 changed files with 372 additions and 464 deletions.
11 changes: 11 additions & 0 deletions .build/Build.csproj
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>
22 changes: 22 additions & 0 deletions .build/Build.sln
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
48 changes: 48 additions & 0 deletions .build/BuildContext.cs
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");
}
}
}


}
28 changes: 28 additions & 0 deletions .build/BuildTask.cs
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);
}
}
22 changes: 22 additions & 0 deletions .build/DeployToGithubTask.cs
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);
}
}
28 changes: 28 additions & 0 deletions .build/DeployToNuGetTask.cs
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);
}
}
30 changes: 30 additions & 0 deletions .build/PackageTask.cs
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);
}
}
29 changes: 29 additions & 0 deletions .build/Program.cs
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 {}
20 changes: 20 additions & 0 deletions .build/RestoreTask.cs
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);
}
}
18 changes: 18 additions & 0 deletions .build/TestTask.cs
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);
}
}
3 changes: 3 additions & 0 deletions .github/release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@
## 5.1.1
- Resolved issue where using Linked Cels can cause an out of bounds exception.

## 5.1.2
- Resolves issue where AsepriteFile.TryGetSlice always returned false even when slice exists


51 changes: 39 additions & 12 deletions .github/workflows/buildandtest.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,60 @@
name: build-and-test
on:
push:
tags: [v*]
pull_request:
branches:
- 'release'
- 'main'
branches: ['main']


env:
DOTNET_VERSION: '6.0.400'


jobs:
build:
build-test-pack-job:
name: "Build-Test-Pack"
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- name: "Clone Repository"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET
- name: "Setup .NET"
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Cake Target Test
shell: bash
run: |
cd ./.tools
dotnet tool restore
dotnet cake --target=Test
- name: "CAKE (Build -> Test -> Package)"
run: dotnet run --project ./.build/Build.csproj -- --target=Default

- name: "Upload Artifacts For Deploy"
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@main
with:
name: MonoGame.Aseprite
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@v3
with:
name: MonoGame.Aseprite
path: artifacts

- name: "Push Packages"
run: dotnet run --project ./.build/Build.csproj -- --target=Deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_ACCESS_TOKEN: ${{ secrets.NUGET_ACCESS_TOKEN }}
2 changes: 1 addition & 1 deletion .nuget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A Cross Platform C# Library That Adds Support For Aseprite Files in MonoGame Projects.

[![build-and-test](https://github.com/AristurtleDev/monogame-aseprite/actions/workflows/buildandtest.yml/badge.svg)](https://github.com/AristurtleDev/monogame-aseprite/actions/workflows/buildandtest.yml)
[![Nuget 5.1.1](https://img.shields.io/nuget/v/MonoGame.Aseprite?color=blue&style=flat-square)](https://www.nuget.org/packages/MonoGame.Aseprite/5.1.1)
[![Nuget 5.1.2](https://img.shields.io/nuget/v/MonoGame.Aseprite?color=blue&style=flat-square)](https://www.nuget.org/packages/MonoGame.Aseprite/5.1.2)
[![License: MIT](https://img.shields.io/badge/📃%20license-MIT-blue?style=flat)](LICENSE)
[![Twitter](https://img.shields.io/badge/%20-Share%20On%20Twitter-555?style=flat&logo=twitter)](https://twitter.com/intent/tweet?text=MonoGame.Aseprite%20by%20%40aristurtledev%0A%0AA%20cross-platform%20C%23%20library%20that%20adds%20support%20for%20Aseprite%20files%20in%20MonoGame%20projects.%20https%3A%2F%2Fgithub.com%2FAristurtleDev%2Fmonogame-aseprite%0A%0A%23monogame%20%23aseprite%20%23dotnet%20%23csharp%20%23oss%0A)

Expand Down
18 changes: 0 additions & 18 deletions .tools/.config/dotnet-tools.json

This file was deleted.

Loading

0 comments on commit ce5f41a

Please sign in to comment.