mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-18 13:45:09 +00:00
Backport beta changes
This commit is contained in:
12
.github/workflows/publish.yml
vendored
12
.github/workflows/publish.yml
vendored
@@ -84,3 +84,15 @@ jobs:
|
|||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
npm publish --access public
|
npm publish --access public
|
||||||
|
|
||||||
|
- name: npm install beta
|
||||||
|
working-directory: services
|
||||||
|
if: github.ref == 'refs/heads/beta'
|
||||||
|
env:
|
||||||
|
IS_BETA: yep
|
||||||
|
run: |
|
||||||
|
git status
|
||||||
|
cd clients/ts;
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
npm publish --access public --tag beta
|
||||||
@@ -6,9 +6,36 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Masterminds/semver/v3"
|
||||||
"github.com/getkin/kin-openapi/openapi3"
|
"github.com/getkin/kin-openapi/openapi3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestSemver(t *testing.T) {
|
||||||
|
v, _ := semver.NewVersion("0.0.0-beta1")
|
||||||
|
if incBeta(*v).String() != "0.0.0-beta2" {
|
||||||
|
t.Fatal(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
v1, _ := semver.NewVersion("0.0.1")
|
||||||
|
if !v1.GreaterThan(v) {
|
||||||
|
t.Fatal("no good")
|
||||||
|
}
|
||||||
|
|
||||||
|
v2, _ := semver.NewVersion("0.0.0")
|
||||||
|
if !v2.GreaterThan(v) {
|
||||||
|
t.Fatal("no good")
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.String() != "0.0.0-beta1" {
|
||||||
|
t.Fatal("no good")
|
||||||
|
}
|
||||||
|
|
||||||
|
v3, _ := semver.NewVersion("0.0.0-beta2")
|
||||||
|
if !v3.GreaterThan(v) {
|
||||||
|
t.Fatal("no good")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type tspec struct {
|
type tspec struct {
|
||||||
openapi string
|
openapi string
|
||||||
tsresult string
|
tsresult string
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
@@ -525,6 +526,8 @@ func main() {
|
|||||||
type npmVers struct {
|
type npmVers struct {
|
||||||
Versions []string `json:"versions"`
|
Versions []string `json:"versions"`
|
||||||
}
|
}
|
||||||
|
beta := os.Getenv("IS_BETA") != ""
|
||||||
|
|
||||||
npmOutput := &npmVers{}
|
npmOutput := &npmVers{}
|
||||||
var latest *semver.Version
|
var latest *semver.Version
|
||||||
if len(outp) > 0 {
|
if len(outp) > 0 {
|
||||||
@@ -547,11 +550,26 @@ func main() {
|
|||||||
if v.GreaterThan(latest) {
|
if v.GreaterThan(latest) {
|
||||||
latest = v
|
latest = v
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if latest == nil {
|
if latest == nil {
|
||||||
latest, _ = semver.NewVersion("0.0.0")
|
latest, _ = semver.NewVersion("0.0.0")
|
||||||
}
|
}
|
||||||
newV := latest.IncPatch()
|
|
||||||
|
var newV semver.Version
|
||||||
|
if beta {
|
||||||
|
// bump a beta version
|
||||||
|
if strings.Contains(latest.String(), "beta") {
|
||||||
|
newV = incBeta(*latest)
|
||||||
|
} else {
|
||||||
|
// make beta out of latest non beta version
|
||||||
|
v, _ := semver.NewVersion(latest.IncPatch().String() + "-beta1")
|
||||||
|
newV = *v
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newV = newV.IncPatch()
|
||||||
|
}
|
||||||
|
|
||||||
// add file list to gitignore
|
// add file list to gitignore
|
||||||
f, err = os.OpenFile(filepath.Join(tsPath, ".gitignore"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0744)
|
f, err = os.OpenFile(filepath.Join(tsPath, ".gitignore"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0744)
|
||||||
@@ -603,6 +621,24 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func incBeta(ver semver.Version) semver.Version {
|
||||||
|
s := ver.String()
|
||||||
|
parts := strings.Split(s, "beta")
|
||||||
|
if len(parts) < 2 {
|
||||||
|
panic("not a beta version " + s)
|
||||||
|
}
|
||||||
|
i, err := strconv.ParseInt(parts[1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
v, err := semver.NewVersion(parts[0] + "beta" + fmt.Sprintf("%v", i))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return *v
|
||||||
|
}
|
||||||
|
|
||||||
func schemaToType(language, serviceName, typeName string, schemas map[string]*openapi3.SchemaRef) string {
|
func schemaToType(language, serviceName, typeName string, schemas map[string]*openapi3.SchemaRef) string {
|
||||||
var recurse func(props map[string]*openapi3.SchemaRef, level int) string
|
var recurse func(props map[string]*openapi3.SchemaRef, level int) string
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user