diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
new file mode 100644
index 00000000..b6554f30
--- /dev/null
+++ b/.config/dotnet-tools.json
@@ -0,0 +1,13 @@
+{
+ "version": 1,
+ "isRoot": true,
+ "tools": {
+ "cake.tool": {
+ "version": "5.0.0",
+ "commands": [
+ "dotnet-cake"
+ ],
+ "rollForward": false
+ }
+ }
+}
\ No newline at end of file
diff --git a/.github/workflows/aquamai.yaml b/.github/workflows/aquamai.yaml
index 5030d9d3..d7f7f944 100644
--- a/.github/workflows/aquamai.yaml
+++ b/.github/workflows/aquamai.yaml
@@ -3,11 +3,7 @@ name: AquaMai Build
on:
workflow_dispatch:
push:
- branches:
- - main
pull_request_target:
- branches:
- - main
jobs:
build:
@@ -19,6 +15,11 @@ jobs:
git config --global core.eol lf
- uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Get Git Describe
+ run: echo "GIT_DESCRIBE=$(git describe --tags --always)" >> $env:GITHUB_ENV
- name: Checkout Assets
uses: clansty/checkout@main
@@ -34,7 +35,7 @@ jobs:
shell: cmd
run: |
copy /y build-assets\SDEZ\* Libs
- dotnet build -c Release /p:DefineConstants="CI"
+ powershell ./build.ps1
- name: Prepare artifact
shell: cmd
@@ -50,13 +51,13 @@ 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 = @{
- chat_id = "-1002231087502"
+ chat_id = "351768429"
media = @(
- @{ type = "document"; media = "attach://aquamai_main"; caption = "${{ github.event.commits[0].message }}" },
+ @{ type = "document"; media = "attach://aquamai_main"; caption = "${{ env.GIT_DESCRIBE }}`n${{ github.event.commits[0].message }}" },
@{ type = "document"; media = "attach://aquamai_zh" }
@{ type = "document"; media = "attach://aquamai_en" }
) | ConvertTo-Json
diff --git a/.gitignore b/.gitignore
index df21fd82..979398c4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -371,4 +371,5 @@ MigrationBackup/
# End of https://www.toptal.com/developers/gitignore/api/git,visualstudio
Output
-.idea
+tools
+AquaMai/BuildInfo.g.cs
diff --git a/.idea/.idea.AquaMai/.idea/.gitignore b/.idea/.idea.AquaMai/.idea/.gitignore
new file mode 100644
index 00000000..6f6061ea
--- /dev/null
+++ b/.idea/.idea.AquaMai/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/modules.xml
+/contentModel.xml
+/projectSettingsUpdater.xml
+/.idea.AquaMai.iml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/.idea.AquaMai/.idea/encodings.xml b/.idea/.idea.AquaMai/.idea/encodings.xml
new file mode 100644
index 00000000..df87cf95
--- /dev/null
+++ b/.idea/.idea.AquaMai/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.AquaMai/.idea/indexLayout.xml b/.idea/.idea.AquaMai/.idea/indexLayout.xml
new file mode 100644
index 00000000..7b08163c
--- /dev/null
+++ b/.idea/.idea.AquaMai/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.AquaMai/.idea/inspectionProfiles/Project_Default.xml b/.idea/.idea.AquaMai/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..e00071e6
--- /dev/null
+++ b/.idea/.idea.AquaMai/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.AquaMai/.idea/runConfigurations/build_cake__Build.xml b/.idea/.idea.AquaMai/.idea/runConfigurations/build_cake__Build.xml
new file mode 100644
index 00000000..004a687e
--- /dev/null
+++ b/.idea/.idea.AquaMai/.idea/runConfigurations/build_cake__Build.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.AquaMai/.idea/vcs.xml b/.idea/.idea.AquaMai/.idea/vcs.xml
new file mode 100644
index 00000000..35eb1ddf
--- /dev/null
+++ b/.idea/.idea.AquaMai/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AquaMai.Core/BuildInfo.cs b/AquaMai.Core/BuildInfo.cs
index 709ce367..47cb4199 100644
--- a/AquaMai.Core/BuildInfo.cs
+++ b/AquaMai.Core/BuildInfo.cs
@@ -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;
}
diff --git a/AquaMai.Mods/UX/CiBuildAlert.cs b/AquaMai.Mods/UX/CiBuildAlert.cs
deleted file mode 100644
index 27caa92f..00000000
--- a/AquaMai.Mods/UX/CiBuildAlert.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using AquaMai.Config.Attributes;
-using AquaMai.Core.Attributes;
-using AquaMai.Core.Helpers;
-using AquaMai.Core.Resources;
-using HarmonyLib;
-using Process;
-
-namespace AquaMai.Mods.UX;
-
-[ConfigSection(exampleHidden: true, defaultOn: true)]
-[EnableIf(nameof(isCiBuild))]
-public class CiBuildAlert
-{
-# if CI
- private static readonly bool isCiBuild = true;
-# else
- private static readonly bool isCiBuild = false;
-# endif
-
- [HarmonyPatch(typeof(AdvertiseProcess), "OnStart")]
- [HarmonyPostfix]
- public static void OnStart(AdvertiseProcess __instance)
- {
- MessageHelper.ShowMessage(Locale.CiBuildAlertContent, title: Locale.CiBuildAlertTitle);
- }
-}
diff --git a/AquaMai/BuildInfo.cs b/AquaMai/BuildInfo.cs
index 7cdbf41d..96d4d10b 100644
--- a/AquaMai/BuildInfo.cs
+++ b/AquaMai/BuildInfo.cs
@@ -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;
}
diff --git a/AquaMai/Properties/AssemblyInfo.cs b/AquaMai/Properties/AssemblyInfo.cs
index e566a535..08009822 100644
--- a/AquaMai/Properties/AssemblyInfo.cs
+++ b/AquaMai/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using MelonLoader;
[assembly: AssemblyCopyright("Created by " + AquaMai.BuildInfo.Author)]
[assembly: AssemblyTrademark(AquaMai.BuildInfo.Company)]
[assembly: AssemblyVersion(AquaMai.BuildInfo.Version)]
-[assembly: AssemblyFileVersion(AquaMai.BuildInfo.Version)]
-[assembly: MelonInfo(typeof(AquaMai.AquaMai), AquaMai.BuildInfo.Name, AquaMai.BuildInfo.Version, AquaMai.BuildInfo.Author, AquaMai.BuildInfo.DownloadLink)]
+[assembly: AssemblyFileVersion(AquaMai.BuildInfo.GitVersion)]
+[assembly: MelonInfo(typeof(AquaMai.AquaMai), AquaMai.BuildInfo.Name, AquaMai.BuildInfo.GitVersion, AquaMai.BuildInfo.Author, AquaMai.BuildInfo.DownloadLink)]
[assembly: MelonColor()]
[assembly: HarmonyDontPatchAll]
diff --git a/README.md b/README.md
index 3c5c1fec..10c08d25 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/build.cake b/build.cake
new file mode 100644
index 00000000..2382a5fb
--- /dev/null
+++ b/build.cake
@@ -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).Substring(1); // 获取 git describe 的输出
+ var buildDate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
+
+ var shortVers = gitDescribe.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("PreBuild")
+ .IsDependentOn("Restore")
+ .Does(() =>
+{
+ // 使用 dotnet build 进行构建
+ DotNetBuild("./AquaMai.sln", new DotNetBuildSettings
+ {
+ Configuration = configuration
+ });
+});
+
+RunTarget(target);
diff --git a/build.ps1 b/build.ps1
new file mode 100644
index 00000000..21821d29
--- /dev/null
+++ b/build.ps1
@@ -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 }