diff --git a/main.go b/main.go index bee419f..e16faae 100644 --- a/main.go +++ b/main.go @@ -13,14 +13,13 @@ func main() { var source_dir = flag.String("s", "", "Path to image folder (/srv/fwuploads-tmp/)") var target_dir = flag.String("t", "", "Path to image folder in public (/srv/fwuploads/troisdorf)") var branch = flag.String("b", "", "Branch to work with") - var version = flag.String("v", "", "which version should be released") var dryrun = flag.Bool("d", false, "Dryrun, just show changes on filesystem") flag.Parse() sdir := *source_dir tdir := *target_dir br := *branch - + version := readVersions(*branch) var source_dir_branch string = sdir + br + "/images/" var target_dir_branch string = tdir + br + "/images/" @@ -32,7 +31,7 @@ func main() { log.Println("Error generating Manifest file: ", err) } } - release_branch(*branch, source_dir_branch, target_dir_branch, *dryrun, *version) + release_branch(*branch, source_dir_branch, target_dir_branch, *dryrun, version) } } diff --git a/manifest.go b/manifest.go index 4c52cc8..b1374e9 100644 --- a/manifest.go +++ b/manifest.go @@ -60,7 +60,7 @@ func split_filenames(files []fs.FileInfo, dir string) []Files { func build_manifest(files []Files, dir string) error { // Datei zum Schreiben öffnen release := strings.Split(files[0].Release, "-") - file, err := os.Create(dir + release[0] + ".manifest") + file, err := os.Create(dir + release[1] + ".manifest") if err != nil { fmt.Println("error creating manifest file") return err @@ -72,7 +72,7 @@ func build_manifest(files []Files, dir string) error { // Datum im gewünschten Format formatieren formatted := now.Format("2006-01-02 15:04:05-07:00") - branch_line := "BRANCH=" + release[0] + "\n" + branch_line := "BRANCH=" + release[1] + "\n" date_line := "DATE=" + formatted + "\n" prio_line := "PRIORITY=0" + "\n" @@ -104,6 +104,6 @@ func build_manifest(files []Files, dir string) error { return err } } - log.Println("Manifest file " + release[0] + ".manifest" + " generated") + log.Println("Manifest file " + release[1] + ".manifest" + " generated") return err } diff --git a/release.go b/release.go index 0e84576..faef05e 100644 --- a/release.go +++ b/release.go @@ -1,7 +1,9 @@ package main import ( + "encoding/json" "fmt" + "io/ioutil" "log" "os" "path/filepath" @@ -73,6 +75,25 @@ func GetGluonVersion(path string) string { return "" } -func check_Release() { +func readVersions(branch string) string { + filePath := "release_state.json" + v, err := ioutil.ReadFile(filePath) + if err != nil { + log.Fatalln("Error reading version JSON file!") + } + var data Versions + err = json.Unmarshal(v, &data) + if err != nil { + log.Fatalln("Error in JSON data!") + } + switch branch { + case "stable": + return data.Stable + case "beta": + return data.Beta + case "experimental": + return data.Experimental + } + return "" } diff --git a/release_state.json b/release_state.json new file mode 100644 index 0000000..eff0135 --- /dev/null +++ b/release_state.json @@ -0,0 +1,5 @@ +{ + "stable": "v2022.1.4", + "beta": "v2022.1.5", + "experimental": "v2022.1.4" +} \ No newline at end of file diff --git a/types.go b/types.go index 5b76ea9..1a5c919 100644 --- a/types.go +++ b/types.go @@ -7,3 +7,9 @@ type Files struct { Size int64 Name string } + +type Versions struct { + Stable string `json:"stable"` + Beta string `json:"beta"` + Experimental string `json:"experimental"` +}