mirror of
https://github.com/hykilpikonna/AquaDX.git
synced 2026-08-25 18:54:26 -05:00
[+] Build with cake and commit id in version (#11)
* [+] Build with cake * ci * ci * fetch-tags * fetch-depth: 0 * melonloader 显示 Git 版本 * remove ci build alert * set FileVersion to git version * add describe to tg * fix
This commit is contained in:
13
.config/dotnet-tools.json
Normal file
13
.config/dotnet-tools.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"cake.tool": {
|
||||
"version": "5.0.0",
|
||||
"commands": [
|
||||
"dotnet-cake"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
17
.github/workflows/aquamai.yaml
vendored
17
.github/workflows/aquamai.yaml
vendored
@@ -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
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -371,4 +371,5 @@ MigrationBackup/
|
||||
# End of https://www.toptal.com/developers/gitignore/api/git,visualstudio
|
||||
|
||||
Output
|
||||
.idea
|
||||
tools
|
||||
AquaMai/BuildInfo.g.cs
|
||||
|
||||
13
.idea/.idea.AquaMai/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.AquaMai/.idea/.gitignore
generated
vendored
Normal file
@@ -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
|
||||
4
.idea/.idea.AquaMai/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.AquaMai/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
.idea/.idea.AquaMai/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.AquaMai/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/.idea.AquaMai/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/.idea.AquaMai/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="TEXT ATTRIBUTES" enabled_by_default="true" editorAttributes="CONSIDERATION_ATTRIBUTES" />
|
||||
</profile>
|
||||
</component>
|
||||
7
.idea/.idea.AquaMai/.idea/runConfigurations/build_cake__Build.xml
generated
Normal file
7
.idea/.idea.AquaMai/.idea/runConfigurations/build_cake__Build.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="build.cake: Build" type="CAKE_CONFIGURATION" factoryName="Cake configuration factory">
|
||||
<option name="additionalArguments" />
|
||||
<option name="taskName" value="Build" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
6
.idea/.idea.AquaMai/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.AquaMai/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
57
build.cake
Normal file
57
build.cake
Normal file
@@ -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);
|
||||
13
build.ps1
Normal file
13
build.ps1
Normal file
@@ -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 }
|
||||
Reference in New Issue
Block a user