Skip to content

Commit 2bd0372

Browse files
committed
[+] Build with cake
1 parent f6e8f4e commit 2bd0372

File tree

14 files changed

+137
-13
lines changed

14 files changed

+137
-13
lines changed

.config/dotnet-tools.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"cake.tool": {
6+
"version": "5.0.0",
7+
"commands": [
8+
"dotnet-cake"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

.github/workflows/aquamai.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ name: AquaMai Build
33
on:
44
workflow_dispatch:
55
push:
6-
branches:
7-
- main
86
pull_request_target:
9-
branches:
10-
- main
117

128
jobs:
139
build:
@@ -50,7 +46,7 @@ jobs:
5046
path: Output\Upload
5147

5248
- name: Send to Telegram
53-
if: github.event_name != 'pull_request_target'
49+
if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/main'
5450
run: |
5551
$Uri = "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMediaGroup"
5652
$Form = @{

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,4 +371,5 @@ MigrationBackup/
371371
# End of https://www.toptal.com/developers/gitignore/api/git,visualstudio
372372

373373
Output
374-
.idea
374+
tools
375+
AquaMai/BuildInfo.g.cs

.idea/.idea.AquaMai/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.AquaMai/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.AquaMai/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.AquaMai/.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.AquaMai/.idea/runConfigurations/build_cake__Build.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.AquaMai/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AquaMai.Core/BuildInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public static class BuildInfo
1010
public static string Author;
1111
public static string Company;
1212
public static string Version;
13+
public static string GitVersion;
14+
public static string BuildDate;
1315
public static string DownloadLink;
1416
}
1517

AquaMai/BuildInfo.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
namespace AquaMai;
22

3-
public static class BuildInfo
3+
public static partial class BuildInfo
44
{
55
public const string Name = "AquaMai";
66
public const string Description = "Mod for Sinmai";
77
public const string Author = "Aza ft. Clansty ft. Menci";
88
public const string Company = null;
9-
public const string Version = "1.3.3";
109
public const string DownloadLink = null;
1110
}
1211

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ This mod is heavily WIP. More details will be added as the development progresse
4141
## Development
4242

4343
1. Copy `Assembly-CSharp.dll` to `Libs` folder.
44-
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)
45-
3. Open `AquaMai.sln` in JetBrains Rider.
46-
4. Build the solution.
47-
5. Copy `Output/AquaMai.dll` to `Mods` folder.
48-
6. Configure and copy `AquaMai.toml` to the same folder as your game executable: `Sinmai.exe`
44+
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)
45+
1. Run `build.ps1`.
46+
1. Copy `Output/AquaMai.dll` to `Mods` folder.
47+
1. Configure and copy `AquaMai.toml` to the same folder as your game executable: `Sinmai.exe`
4948

5049
## Relevant Links
5150

build.cake

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#addin nuget:?package=Cake.Git&version=5.0.1
2+
#addin nuget:?package=Cake.FileHelpers&version=7.0.0
3+
4+
var target = Argument("target", "Build");
5+
var configuration = Argument("configuration", "Release");
6+
7+
Task("Restore")
8+
.Does(() =>
9+
{
10+
// 运行 dotnet restore
11+
DotNetRestore("./AquaMai.sln");
12+
});
13+
14+
Task("PreBuild")
15+
.Does(() =>
16+
{
17+
var gitDescribe = GitDescribe(".", GitDescribeStrategy.Tags); // 获取 git describe 的输出
18+
var buildDate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
19+
20+
var shortVers = gitDescribe.Substring(1).Split('-');
21+
string shortVer;
22+
if (shortVers.Length > 1)
23+
{
24+
shortVer = $"{shortVers[0]}.{shortVers[1]}";
25+
}
26+
else
27+
{
28+
shortVer = shortVers[0];
29+
}
30+
31+
var versionContent = $@"
32+
// Auto-generated file. Do not modify manually.
33+
namespace AquaMai;
34+
35+
public static partial class BuildInfo
36+
{{
37+
public const string Version = ""{shortVer}"";
38+
public const string GitVersion = ""{gitDescribe}"";
39+
public const string BuildDate = ""{buildDate}"";
40+
}}
41+
";
42+
FileWriteText("./AquaMai/BuildInfo.g.cs", versionContent);
43+
});
44+
45+
Task("Build")
46+
.IsDependentOn("Restore")
47+
.IsDependentOn("PreBuild")
48+
.Does(() =>
49+
{
50+
// 使用 dotnet build 进行构建
51+
DotNetBuild("./AquaMai.sln", new DotNetBuildSettings
52+
{
53+
Configuration = configuration
54+
});
55+
});
56+
57+
RunTarget(target);

build.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
Set-Location -LiteralPath $PSScriptRoot
4+
5+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
6+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
7+
$env:DOTNET_NOLOGO = '1'
8+
9+
dotnet tool restore
10+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
11+
12+
dotnet cake @args
13+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

0 commit comments

Comments
 (0)