diff --git a/Makefile b/Makefile index a6939bf7..5989a391 100644 --- a/Makefile +++ b/Makefile @@ -93,4 +93,8 @@ container-local: kubevpn-linux-amd64 .PHONY: container-test container-test: kubevpn-linux-amd64 - docker buildx build --platform linux/amd64,linux/arm64 -t docker.io/naison/kubevpn:test -f $(BUILD_DIR)/test.Dockerfile --push . \ No newline at end of file + docker buildx build --platform linux/amd64,linux/arm64 -t docker.io/naison/kubevpn:test -f $(BUILD_DIR)/test.Dockerfile --push . + +.PHONY: version +version: + go run github.com/wencaiwulue/kubevpn/pkg/util/krew \ No newline at end of file diff --git a/pkg/util/krew/main.go b/pkg/util/krew/main.go index 86afa7b5..4647348f 100644 --- a/pkg/util/krew/main.go +++ b/pkg/util/krew/main.go @@ -2,8 +2,11 @@ package main import ( "bytes" + "fmt" "os" + "os/exec" "path" + "strings" "sync" "text/template" @@ -11,10 +14,21 @@ import ( ) func main() { - filePath := "../../../.github/krew.yaml" - value := map[string]string{"TagName": "v1.1.20"} + // git describe --tags `git rev-list --tags --max-count=1` + commitId, err2 := exec.Command("git", "rev-list", "--tags", "--max-count=1").Output() + if err2 != nil { + panic(err2) + } + tag, err2 := exec.Command("git", "describe", "--tags", strings.TrimSpace(string(commitId))).Output() + if err2 != nil { + panic(err2) + } + fmt.Printf("latest tag is %s", strings.TrimSpace(string(tag))) + tplFile := ".github/krew.yaml" + dstFile := "plugins/kubevpn.yaml" + value := map[string]string{"TagName": strings.TrimSpace(string(tag))} - name := path.Base(filePath) + name := path.Base(tplFile) var links []string t := template.New(name).Funcs(map[string]interface{}{ "addURIAndSha": func(url, tag string) string { @@ -39,7 +53,7 @@ func main() { }, }) - templateObject, err := t.ParseFiles(filePath) + templateObject, err := t.ParseFiles(tplFile) if err != nil { panic(err) } @@ -67,12 +81,12 @@ func main() { }(i, link) } wg.Wait() - processTemplate, err := ProcessTemplate(filePath, value, sha256Map) + processTemplate, err := ProcessTemplate(tplFile, value, sha256Map) if err != nil { panic(err) } println(string(processTemplate)) - err = os.WriteFile("../../../plugins/kubevpn.yaml", processTemplate, 0644) + err = os.WriteFile(dstFile, processTemplate, 0644) if err != nil { panic(err) } diff --git a/plugins/kubevpn.yaml b/plugins/kubevpn.yaml index bde4bed2..a264280d 100644 --- a/plugins/kubevpn.yaml +++ b/plugins/kubevpn.yaml @@ -3,7 +3,7 @@ kind: Plugin metadata: name: kubevpn spec: - version: v1.1.27 + version: v1.1.28 homepage: https://github.com/wencaiwulue/kubevpn shortDescription: "A vpn tunnel tools which can connect to kubernetes cluster network" description: | @@ -17,8 +17,8 @@ spec: matchLabels: os: windows arch: amd64 - uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.27/kubevpn_v1.1.27_windows_amd64.zip - sha256: bef24ccec9cac8f5c205e6608a17697f845ba96aa8b7ff0b6c90ee8a28abfeaf + uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.28/kubevpn_v1.1.28_windows_amd64.zip + sha256: c1292f94523bc51ef3c68b7c01c1c21beb8d3ca6be48a4b05938c139092cd0ed files: - from: ./bin/kubevpn.exe to: . @@ -29,8 +29,8 @@ spec: matchLabels: os: windows arch: arm64 - uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.27/kubevpn_v1.1.27_windows_arm64.zip - sha256: a0f5c1c8627341f9833468c85a34dd5c9ee33416525d0137975e7c856c80e6dd + uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.28/kubevpn_v1.1.28_windows_arm64.zip + sha256: b10b16769a791f229ac24a0aa642f59150fcb73d449e2bb83921239f7e77fb48 files: - from: ./bin/kubevpn.exe to: . @@ -41,8 +41,8 @@ spec: matchLabels: os: windows arch: 386 - uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.27/kubevpn_v1.1.27_windows_386.zip - sha256: 5dde5bec315490d7a95ee8444c1ce106767d7057f493e6e7989d04f12e7178be + uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.28/kubevpn_v1.1.28_windows_386.zip + sha256: 03819683d26210669a9240e6943fc20af6a8a62b91df7aa92b9ee38be01ffd07 files: - from: ./bin/kubevpn.exe to: . @@ -53,8 +53,8 @@ spec: matchLabels: os: linux arch: amd64 - uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.27/kubevpn_v1.1.27_linux_amd64.zip - sha256: 621c3b3021ed8d2ee0ba11e20f5bf528a4ee309190dbb131a8ef0f3d6fb3b04a + uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.28/kubevpn_v1.1.28_linux_amd64.zip + sha256: 544b2c53de9fdb1ade5a7b4487d08526596f0fc8e540e76510409b62aedeeeb4 files: - from: ./bin/kubevpn to: . @@ -65,8 +65,8 @@ spec: matchLabels: os: linux arch: arm64 - uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.27/kubevpn_v1.1.27_linux_arm64.zip - sha256: b3abe82f1da20521dd3468157e330016646e1d5fce023f5c23535b7b403244df + uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.28/kubevpn_v1.1.28_linux_arm64.zip + sha256: c99df8f999e151b448b2f48f3d07eaf4f9bc722542ba7f4a20904412a25bcbfd files: - from: ./bin/kubevpn to: . @@ -77,8 +77,8 @@ spec: matchLabels: os: linux arch: 386 - uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.27/kubevpn_v1.1.27_linux_386.zip - sha256: 96003acf4a951c9f438760f1541a8af4ccbbf6a3f7a70d9477c5a04e87371161 + uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.28/kubevpn_v1.1.28_linux_386.zip + sha256: f623dcf8c84ce9d662f5516dbe2272d288d550277139adc105dcea23da643778 files: - from: ./bin/kubevpn to: . @@ -89,8 +89,8 @@ spec: matchLabels: os: darwin arch: amd64 - uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.27/kubevpn_v1.1.27_darwin_amd64.zip - sha256: d522214a1f2067610dc5f9dd4b2c660cbaecc5a881f5ebd7b3bd0fefbb5e5f89 + uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.28/kubevpn_v1.1.28_darwin_amd64.zip + sha256: 917fe6b1bc757ceca3ecb1bebbe5b08e7b1a96aebcff5da54fe29f270b89805c files: - from: ./bin/kubevpn to: . @@ -101,8 +101,8 @@ spec: matchLabels: os: darwin arch: arm64 - uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.27/kubevpn_v1.1.27_darwin_arm64.zip - sha256: 93e1b934332ef96551620595923083366ec59af4ad59aecdf16b4f65f9347bcc + uri: https://github.com/wencaiwulue/kubevpn/releases/download/v1.1.28/kubevpn_v1.1.28_darwin_arm64.zip + sha256: c86532abfdd0b582c001a994921157abbbb3fcc5f12f28ec76a8e6afbc357916 files: - from: ./bin/kubevpn to: .