Skip to content

Commit

Permalink
[+] Build with cake
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Jan 20, 2025
1 parent f6e8f4e commit 2bd0372
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 13 deletions.
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "5.0.0",
"commands": [
"dotnet-cake"
],
"rollForward": false
}
}
}
6 changes: 1 addition & 5 deletions .github/workflows/aquamai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ name: AquaMai Build
on:
workflow_dispatch:
push:
branches:
- main
pull_request_target:
branches:
- main

jobs:
build:
Expand Down Expand Up @@ -50,7 +46,7 @@ jobs:
path: Output\Upload

- name: Send to Telegram
if: github.event_name != 'pull_request_target'
if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/main'
run: |
$Uri = "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMediaGroup"
$Form = @{
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,5 @@ MigrationBackup/
# End of https://www.toptal.com/developers/gitignore/api/git,visualstudio

Output
.idea
tools
AquaMai/BuildInfo.g.cs
13 changes: 13 additions & 0 deletions .idea/.idea.AquaMai/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.AquaMai/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.AquaMai/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.AquaMai/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions AquaMai.Core/BuildInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static class BuildInfo
public static string Author;
public static string Company;
public static string Version;
public static string GitVersion;
public static string BuildDate;
public static string DownloadLink;
}

3 changes: 1 addition & 2 deletions AquaMai/BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
namespace AquaMai;

public static class BuildInfo
public static partial class BuildInfo
{
public const string Name = "AquaMai";
public const string Description = "Mod for Sinmai";
public const string Author = "Aza ft. Clansty ft. Menci";
public const string Company = null;
public const string Version = "1.3.3";
public const string DownloadLink = null;
}

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ This mod is heavily WIP. More details will be added as the development progresse
## Development

1. Copy `Assembly-CSharp.dll` to `Libs` folder.
2. Install [.NET Framework 4.7.2 Developer Pack](https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net472-developer-pack-offline-installer)
3. Open `AquaMai.sln` in JetBrains Rider.
4. Build the solution.
5. Copy `Output/AquaMai.dll` to `Mods` folder.
6. Configure and copy `AquaMai.toml` to the same folder as your game executable: `Sinmai.exe`
1. Install [.NET Framework 4.7.2 Developer Pack](https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net472-developer-pack-offline-installer)
1. Run `build.ps1`.
1. Copy `Output/AquaMai.dll` to `Mods` folder.
1. Configure and copy `AquaMai.toml` to the same folder as your game executable: `Sinmai.exe`

## Relevant Links

Expand Down
57 changes: 57 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#addin nuget:?package=Cake.Git&version=5.0.1
#addin nuget:?package=Cake.FileHelpers&version=7.0.0

var target = Argument("target", "Build");
var configuration = Argument("configuration", "Release");

Task("Restore")
.Does(() =>
{
// 运行 dotnet restore
DotNetRestore("./AquaMai.sln");
});

Task("PreBuild")
.Does(() =>
{
var gitDescribe = GitDescribe(".", GitDescribeStrategy.Tags); // 获取 git describe 的输出
var buildDate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");

var shortVers = gitDescribe.Substring(1).Split('-');
string shortVer;
if (shortVers.Length > 1)
{
shortVer = $"{shortVers[0]}.{shortVers[1]}";
}
else
{
shortVer = shortVers[0];
}

var versionContent = $@"
// Auto-generated file. Do not modify manually.
namespace AquaMai;
public static partial class BuildInfo
{{
public const string Version = ""{shortVer}"";
public const string GitVersion = ""{gitDescribe}"";
public const string BuildDate = ""{buildDate}"";
}}
";
FileWriteText("./AquaMai/BuildInfo.g.cs", versionContent);
});

Task("Build")
.IsDependentOn("Restore")
.IsDependentOn("PreBuild")
.Does(() =>
{
// 使用 dotnet build 进行构建
DotNetBuild("./AquaMai.sln", new DotNetBuildSettings
{
Configuration = configuration
});
});

RunTarget(target);
13 changes: 13 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$ErrorActionPreference = 'Stop'

Set-Location -LiteralPath $PSScriptRoot

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
$env:DOTNET_NOLOGO = '1'

dotnet tool restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

dotnet cake @args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

0 comments on commit 2bd0372

Please sign in to comment.