From 078a970e8e1800f9f6ee12eac3bce39d0c523efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=99=93=E4=BC=9F?= Date: Fri, 24 Nov 2023 08:20:41 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=9C=A8=20GitHub=20Actions=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=20=E4=B8=AD=E5=8F=91=E5=B8=83=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E9=9C=80=E6=8E=A8=E9=80=81=20Git=20=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=EF=BC=88=E5=BD=93=E5=89=8D=E5=B7=A5=E4=BD=9C=E5=8C=BA=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=B7=B2=E5=AD=98=E5=9C=A8=E4=BA=8E?= =?UTF-8?q?=20GitHub=20=E4=BB=93=E5=BA=93=E4=B8=AD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/github.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/api/github.go b/api/github.go index 8eb23ef..8803bd6 100644 --- a/api/github.go +++ b/api/github.go @@ -60,12 +60,17 @@ func Github(prerelease bool, context *cli.Context) error { // 用于判断是否处于 GitHub Actions 环境 githubSha := os.Getenv("GITHUB_SHA") - log.Printf("GITHUB_SHA:%s", githubSha) - - // 推送标签 - err = GitPushTag("https://github.com", githubRepository, githubUsername, githubToken, tag) - if err != nil { - return err + if githubSha != "" { + log.Printf("GITHUB_SHA:%s", githubSha) + log.Printf("在 GitHub Actions 环境 中发布,无需推送 Git 标签(当前工作区的代码,已存在于 GitHub 仓库中)") + } else { + log.Printf("使用 Git 推送标签 开始") + // 推送标签 + err = GitPushTag("https://github.com", githubRepository, githubUsername, githubToken, tag) + if err != nil { + return err + } + log.Printf("使用 Git 推送标签 结束") } // 发布