refactor: clean up and remove version check
This commit is contained in:
parent
89cdd01698
commit
7c945f0a2d
|
@ -8,14 +8,10 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bytes"
|
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -51,22 +47,6 @@ func main() {
|
||||||
}
|
}
|
||||||
tag := releases[0].TagName
|
tag := releases[0].TagName
|
||||||
|
|
||||||
current, err := ioutil.ReadFile("current_version.txt")
|
|
||||||
if err != nil {
|
|
||||||
switch {
|
|
||||||
case errors.Is(err, fs.ErrNotExist):
|
|
||||||
// no problem, just do it
|
|
||||||
default:
|
|
||||||
log.Fatalf("unable to check version in current_version.txt: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cv := string(bytes.TrimRight(current, "\n"))
|
|
||||||
|
|
||||||
if cv == tag {
|
|
||||||
log.Print("version is current, nothing to do")
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("downloading release %s...", tag)
|
log.Printf("downloading release %s...", tag)
|
||||||
|
|
||||||
resp, err = http.Get(fmt.Sprintf("https://github.com/swagger-api/swagger-ui/archive/%s.tar.gz", tag))
|
resp, err = http.Get(fmt.Sprintf("https://github.com/swagger-api/swagger-ui/archive/%s.tar.gz", tag))
|
||||||
|
@ -120,7 +100,6 @@ func main() {
|
||||||
newInit = regexp.MustCompile(`,?\s+SwaggerUIStandalonePreset.*\n`).ReplaceAllLiteral(newInit, []byte("\n"))
|
newInit = regexp.MustCompile(`,?\s+SwaggerUIStandalonePreset.*\n`).ReplaceAllLiteral(newInit, []byte("\n"))
|
||||||
newInit = regexp.MustCompile(`(?s),\s+plugins: \[.*],\n`).ReplaceAllLiteral(newInit, []byte("\n"))
|
newInit = regexp.MustCompile(`(?s),\s+plugins: \[.*],\n`).ReplaceAllLiteral(newInit, []byte("\n"))
|
||||||
newInit = regexp.MustCompile(`\n\s*layout:.*\n`).ReplaceAllLiteral(newInit, []byte("\n"))
|
newInit = regexp.MustCompile(`\n\s*layout:.*\n`).ReplaceAllLiteral(newInit, []byte("\n"))
|
||||||
//fmt.Println(string(newInit))
|
|
||||||
newinitFile, err := os.Create(filepath.Join("embed", "swagger-initializer.js"))
|
newinitFile, err := os.Create(filepath.Join("embed", "swagger-initializer.js"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error re-creating swagger-initializer.js file: %v", err)
|
log.Fatalf("error re-creating swagger-initializer.js file: %v", err)
|
||||||
|
@ -135,5 +114,4 @@ func main() {
|
||||||
}
|
}
|
||||||
defer newcv.Close()
|
defer newcv.Close()
|
||||||
newcv.WriteString(tag)
|
newcv.WriteString(tag)
|
||||||
log.Printf("updated swaggerui from %s => %s, please check templated swagger-initializer.js and retag repo", cv, tag)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue