Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 Fix path in artifact name for windows upload #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions release.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"
"os"
"path"
"path/filepath"

"code.gitea.io/sdk/gitea"
)
Expand Down Expand Up @@ -86,12 +86,12 @@ func (rc *releaseClient) uploadFiles(releaseID int64, files []string) error {
files:
for _, file := range files {
for _, attachment := range attachments {
if attachment.Name == path.Base(file) {
if attachment.Name == filepath.Base(file) {
switch rc.FileExists {
case "overwrite":
// do nothing
case "fail":
return fmt.Errorf("Asset file %s already exists", path.Base(file))
return fmt.Errorf("Asset file %s already exists", filepath.Base(file))
case "skip":
fmt.Printf("Skipping pre-existing %s artifact\n", attachment.Name)
continue files
Expand All @@ -112,7 +112,7 @@ files:
}

for _, attachment := range attachments {
if attachment.Name == path.Base(file) {
if attachment.Name == filepath.Base(file) {
if _, err := rc.Client.DeleteReleaseAttachment(rc.Owner, rc.Repo, releaseID, attachment.ID); err != nil {
return fmt.Errorf("Failed to delete %s artifact: %s", file, err)
}
Expand All @@ -121,7 +121,7 @@ files:
}
}

if _, _, err = rc.Client.CreateReleaseAttachment(rc.Owner, rc.Repo, releaseID, handle, path.Base(file)); err != nil {
if _, _, err = rc.Client.CreateReleaseAttachment(rc.Owner, rc.Repo, releaseID, handle, filepath.Base(file)); err != nil {
return fmt.Errorf("Failed to upload %s artifact: %s", file, err)
}

Expand Down
3 changes: 2 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"hash/crc32"
"io"
"os"
"path/filepath"
"strconv"

"golang.org/x/crypto/blake2b"
Expand Down Expand Up @@ -70,7 +71,7 @@ func writeChecksums(files, methods []string) ([]string, error) {
return nil, err
}

checksums[method] = append(checksums[method], hash, file)
checksums[method] = append(checksums[method], hash, filepath.Base(file))
}
}

Expand Down