Skip to content

Commit 3b7877f

Browse files
improved github actions workarounds for different OS
1 parent 25716ef commit 3b7877f

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

cmd/upload.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,20 @@ func getToolShortName(fullName string) string {
7171
func getRelativePath(baseDir string, fullURI string) string {
7272

7373
localPath := fullURI
74+
7475
// GitHub Actions workaround
75-
if strings.Contains(baseDir, "/home/runner/work/") {
76-
localPath = filepath.Join(baseDir, fullURI)
76+
baseDirIndicators := []string{
77+
"/home/runner/work/", // Linux
78+
"/Users/runner/work/", // macOS
79+
"/__w/", // Docker Containers
80+
"\\a\\", // Windows (D:\a\)
81+
}
82+
83+
for _, sub := range baseDirIndicators {
84+
if strings.Contains(baseDir, sub) {
85+
// We are likely in a GitHub Runner
86+
localPath = filepath.Join(baseDir, fullURI)
87+
}
7788
}
7889
u, err := url.Parse(fullURI)
7990
if err == nil && u.Scheme == "file" {
@@ -82,6 +93,7 @@ func getRelativePath(baseDir string, fullURI string) string {
8293
}
8394

8495
relativePath, err := filepath.Rel(baseDir, localPath)
96+
fmt.Println(baseDir, localPath)
8597
if err != nil {
8698
// Fallback to the normalized absolute path if calculation fails
8799
fmt.Printf("Warning: Could not get relative path for '%s' relative to '%s': %v. Using absolute path.\n", localPath, baseDir, err)

0 commit comments

Comments
 (0)