Added target version
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
Stefan Hoffmann 2023-06-02 19:04:31 +02:00
parent 7029d039a3
commit 8d77819f57
Signed by: stefan
GPG Key ID: 8EFC7042BF8D5CDD
5 changed files with 38 additions and 7 deletions

View File

@ -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)
}
}

View File

@ -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
}

View File

@ -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 ""
}

5
release_state.json Normal file
View File

@ -0,0 +1,5 @@
{
"stable": "v2022.1.4",
"beta": "v2022.1.5",
"experimental": "v2022.1.4"
}

View File

@ -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"`
}