|
|
|
@ -29,7 +29,7 @@ func main() {
|
|
|
|
|
preRelease, _ := strconv.ParseBool(gha.GetInput("pre_release"))
|
|
|
|
|
draft, _ := strconv.ParseBool(gha.GetInput("draft"))
|
|
|
|
|
if title == "" {
|
|
|
|
|
title = ctx.RefName
|
|
|
|
|
title = strings.Replace(ctx.RefName, "refs/tags/", "", 1)
|
|
|
|
|
}
|
|
|
|
|
if apiKey == "" {
|
|
|
|
|
apiKey = os.Getenv("GITHUB_TOKEN")
|
|
|
|
@ -148,6 +148,14 @@ func createOrGetRelease(ctx *gha.GitHubContext, c *gitea.Client, owner, repo str
|
|
|
|
|
return release, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getFilename(ctx *gha.GitHubContext, path string) string {
|
|
|
|
|
fileKey := gha.GetInput("file_key")
|
|
|
|
|
fileName := filepath.Base(path)
|
|
|
|
|
ext := filepath.Ext(fileName)
|
|
|
|
|
filePath := strings.TrimSuffix(fileName, ext)
|
|
|
|
|
return filePath + fileKey + ext
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func uploadFiles(ctx *gha.GitHubContext, c *gitea.Client, owner, repo string, releaseID int64, files []string) error {
|
|
|
|
|
attachments, _, err := c.ListReleaseAttachments(owner, repo, releaseID, gitea.ListReleaseAttachmentsOptions{})
|
|
|
|
|
if err != nil {
|
|
|
|
@ -171,7 +179,7 @@ func uploadFiles(ctx *gha.GitHubContext, c *gitea.Client, owner, repo string, re
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _, _, err = c.CreateReleaseAttachment(owner, repo, releaseID, f, filepath.Base(file)); err != nil {
|
|
|
|
|
if _, _, err = c.CreateReleaseAttachment(owner, repo, releaseID, f, getFilename(ctx, file)); err != nil {
|
|
|
|
|
f.Close()
|
|
|
|
|
return fmt.Errorf("failed to upload release attachment %s: %w", file, err)
|
|
|
|
|
}
|
|
|
|
|