From 657efa49767343949b2c53b10af565a99695fedb Mon Sep 17 00:00:00 2001 From: myrqs Date: Thu, 4 May 2023 16:32:01 +0800 Subject: [PATCH] fix: use filepath for attachment name to handle naming when running on windows --- main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 098fdf8..8da279e 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "fmt" "net/http" "os" - "path" "path/filepath" "strconv" "strings" @@ -153,7 +152,7 @@ func uploadFiles(ctx *gha.GitHubContext, c *gitea.Client, owner, repo string, re } for _, attachment := range attachments { - if attachment.Name == path.Base(file) { + if attachment.Name == filepath.Base(file) { if _, err := c.DeleteReleaseAttachment(owner, repo, releaseID, attachment.ID); err != nil { f.Close() return fmt.Errorf("failed to delete release attachment %s: %w", file, err) @@ -163,7 +162,7 @@ func uploadFiles(ctx *gha.GitHubContext, c *gitea.Client, owner, repo string, re } } - if _, _, err = c.CreateReleaseAttachment(owner, repo, releaseID, f, path.Base(file)); err != nil { + if _, _, err = c.CreateReleaseAttachment(owner, repo, releaseID, f, filepath.Base(file)); err != nil { f.Close() return fmt.Errorf("failed to upload release attachment %s: %w", file, err) }