From a179e0e838c4ab341fb628470c87f523f322e446 Mon Sep 17 00:00:00 2001 From: qhy040404 <45379733+qhy040404@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:54:15 +0800 Subject: [PATCH] Update build.cake (#1405) --- build.cake | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/build.cake b/build.cake index d99f0191..87c2ec4d 100644 --- a/build.cake +++ b/build.cake @@ -1,5 +1,5 @@ -#tool "nuget:?package=nuget.commandline&version=6.5.0" -#addin nuget:?package=Cake.Http&version=3.0.2 +#tool "nuget:?package=nuget.commandline&version=6.9.1" +#addin nuget:?package=Cake.Http&version=4.0.0 var target = Argument("target", "Build"); var configuration = Argument("configuration", "Release"); @@ -33,18 +33,28 @@ if (GitHubActions.IsRunningOnGitHubActions) repoDir = GitHubActions.Environment.Workflow.Workspace.FullPath; outputPath = System.IO.Path.Combine(repoDir, "src", "output"); - var versionAuth = HasEnvironmentVariable("VERSION_API_TOKEN") ? EnvironmentVariable("VERSION_API_TOKEN") : throw new Exception("Cannot find VERSION_API_TOKEN"); - version = HttpGet( - "https://internal.snapgenshin.cn/BuildIntergration/RequestNewVersion", - new HttpSettings - { - Headers = new Dictionary - { + if (GitHubActions.Environment.PullRequest.IsPullRequest) + { + version = System.DateTime.Now.ToString("yyyy.M.d.0"); + + Information("Is Pull Request. Skip version."); + } + else + { + var versionAuth = HasEnvironmentVariable("VERSION_API_TOKEN") ? EnvironmentVariable("VERSION_API_TOKEN") : throw new Exception("Cannot find VERSION_API_TOKEN"); + version = HttpGet( + "https://internal.snapgenshin.cn/BuildIntergration/RequestNewVersion", + new HttpSettings + { + Headers = new Dictionary + { { "Authorization", versionAuth } - } - } - ); - Information($"Version: {version}"); + } + } + ); + + Information($"Version: {version}"); + } GitHubActions.Commands.SetOutputParameter("version", version); }