Skip to content

Commit

Permalink
fix: normalize file name
Browse files Browse the repository at this point in the history
  • Loading branch information
invakid404 committed May 22, 2024
1 parent dead2a6 commit deadabe
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
)

var (
sourcePattern = regexp.MustCompile("Circle_Linux_Mac_Driver_v([\\d.]+)\\.zip$")
sourcePattern = regexp.MustCompile("v([\\d.]+)\\.zip$")
)

func main() {
Expand Down Expand Up @@ -107,13 +107,21 @@ func main() {
return nil
})

if sourcePath != "" {
if done && sourcePath != "" {
break
}

time.Sleep(100 * time.Millisecond)
}

basePath := filepath.Dir(sourcePath)
targetPath := filepath.Join(basePath, fmt.Sprintf("Circle_Linux_Mac_Driver_v%s.zip", version))

err = os.Rename(sourcePath, targetPath)
if err != nil {
log.Fatalln("failed to rename file:", err)
}

outputFilePath := os.Getenv("GITHUB_OUTPUT")
outputFile, err := os.OpenFile(outputFilePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
Expand All @@ -122,7 +130,7 @@ func main() {

defer outputFile.Close()

if _, err := outputFile.WriteString(fmt.Sprintf("path=%s\nversion=%s\n", sourcePath, version)); err != nil {
if _, err := outputFile.WriteString(fmt.Sprintf("path=%s\nversion=%s\n", targetPath, version)); err != nil {
log.Fatalln("failed to write output:", err)
}

Expand Down

0 comments on commit deadabe

Please sign in to comment.