go-gluon-publisher/release.go

36 lines
760 B
Go
Raw Normal View History

2023-05-29 20:27:28 +00:00
package main
import (
"fmt"
"log"
"os"
)
func release_branch(branch string, source_dir string, target_dir string) {
checkOldFolder, _ := os.ReadDir(source_dir)
checkNewFolder, _ := os.ReadDir(target_dir)
var newImages bool = false
if len(checkOldFolder) > 0 {
newImages = true
}
if newImages {
// delete old firmware files in public folder
for _, file := range checkNewFolder {
err := os.Remove(target_dir + file.Name())
if err != nil {
log.Println("error deleting file: ", err)
} else {
log.Println("removed file: ", file.Name())
}
}
//move new files to folder
for _, file := range checkOldFolder {
os.Rename(source_dir+file.Name(), target_dir+file.Name())
fmt.Println("moved file: ", file.Name())
}
}
}