chore: 尝试优化MaaBuilder一些有的没的

This commit is contained in:
MistEO
2023-05-03 20:20:39 +08:00
parent 2fca17d64f
commit c650d8276f
2 changed files with 12 additions and 12 deletions

View File

@@ -169,12 +169,12 @@ public partial class Build
if (b.GitHubActions.Ref.StartsWith(ReleaseTagRefPrefix))
{
var tag = $"v{b.GitHubActions.Ref.Replace(ReleaseTagRefPrefix, "")}";
var pattern = @"v((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)";
var pattern = @"^v((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)";
var match = Regex.Match(tag, pattern);
if (match.Success)
{
GhTag = tag;
var preReleasePattern = @"v((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*))(-)";
var preReleasePattern = @"^v((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*))(-)";
var preReleaseMatch = Regex.Match(tag, preReleasePattern);
IsPreRelease = preReleaseMatch.Success;
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using Nuke.Common;
using Nuke.Common.Git;
@@ -10,18 +10,18 @@ namespace MaaBuilder;
public partial class Build
{
Target UseRsVersion => _ => _
private Target UseRsVersion => _ => _
.Triggers(SetVersion)
.Executes(() =>
{
Information($"Release Simulation: {Parameters.GhActionWdRsTagName}");
Version = Parameters.GhActionWdRsTagName;
GitHubTasks.GitHubClient = new GitHubClient(new ProductHeaderValue(nameof(NukeBuild)));
});
Target UseCommitVersion => _ => _
private Target UseCommitVersion => _ => _
.Triggers(SetVersion)
.Executes(() =>
{
@@ -29,7 +29,7 @@ public partial class Build
Version = !envReleaseTag.IsNullOrEmpty() ? envReleaseTag : $"{Parameters.BuildTime}-{Parameters.CommitHash}";
});
Target UseTagVersion => _ => _
private Target UseTagVersion => _ => _
.Triggers(SetVersion)
.Executes(() =>
{
@@ -39,8 +39,8 @@ public partial class Build
var repo = GitRepository.FromLocalDirectory(RootDirectory);
Assert.True(repo is not null, "不在 Git Repo 中");
var tag = repo.Tags.FirstOrDefault();
var tag = repo.Tags.ToList().Find(v => v.StartsWith("v"));
if (tag is not null)
{
@@ -63,12 +63,12 @@ public partial class Build
};
LatestTag = Parameters.IsPreRelease ? GetLatestTag() : GetLatestReleaseTag();
Version = Parameters.GhTag;
}
});
Target SetVersion => _ => _
private Target SetVersion => _ => _
.Executes(() =>
{
Information($"当前版本号设置为:{Version}");