From 53fd4f80524c5e850832dcbc59573fe60cac3794 Mon Sep 17 00:00:00 2001 From: James Strong Date: Thu, 15 Jun 2023 08:56:28 -0700 Subject: [PATCH] working on release Signed-off-by: James Strong --- ingressctl/cmd/common.go | 2 +- ingressctl/cmd/helm.go | 15 ++------------- ingressctl/cmd/release.go | 22 +++++++++++----------- ingressctl/cmd/tags.go | 11 ++++++++++- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/ingressctl/cmd/common.go b/ingressctl/cmd/common.go index 1509f5f00..48cbaec03 100644 --- a/ingressctl/cmd/common.go +++ b/ingressctl/cmd/common.go @@ -11,7 +11,7 @@ var DEBUG bool func init() { DEBUG = false - debugENV := os.Getenv("MAGE_DEBUG") + debugENV := os.Getenv("DEBUG") if debugENV == "true" { DEBUG = true } diff --git a/ingressctl/cmd/helm.go b/ingressctl/cmd/helm.go index 62da33b33..d585ff4f3 100644 --- a/ingressctl/cmd/helm.go +++ b/ingressctl/cmd/helm.go @@ -41,11 +41,6 @@ func updateAppVersion() { } -// UpdateVersion Update Helm Version of the Chart -func UpdateVersion(version string) { - updateVersion(version) -} - func currentChartVersion() string { chart, err := chartutil.LoadChartfile(HelmChartPath) CheckIfError(err, "HELM Could not Load Chart") @@ -58,19 +53,13 @@ func currentChartAppVersion() string { return chart.AppVersion } -func updateVersion(version string) { +// UpdateVersion Update Helm Version of the Chart +func UpdateVersion(appVersion string) { Info("HELM Reading File %v", HelmChartPath) chart, err := chartutil.LoadChartfile(HelmChartPath) CheckIfError(err, "HELM Could not Load Chart") - //Get the current tag - //appVersionV, err := getIngressNGINXVersion() - //CheckIfError(err, "HELM Issue Retrieving the Current Ingress Nginx Version") - - //remove the v from TAG - appVersion := version - Info("HELM Ingress-Nginx App Version: %s Chart AppVersion: %s", appVersion, chart.AppVersion) if appVersion == chart.AppVersion { Warning("HELM Ingress NGINX Version didnt change Ingress-Nginx App Version: %s Chart AppVersion: %s", appVersion, chart.AppVersion) diff --git a/ingressctl/cmd/release.go b/ingressctl/cmd/release.go index 90dae0bc0..dc7e87138 100644 --- a/ingressctl/cmd/release.go +++ b/ingressctl/cmd/release.go @@ -38,20 +38,20 @@ import ( ) // var INGRESS_ORG = "kubernetes" // the owner so we can test from forks -var INGRESS_ORG = "strongjz" // the owner so we can test from forks -var INGRESS_REPO = "ingress-nginx" // the repo to pull from -var RELEASE_BRANCH = "main" //we only release from main -var GITHUB_TOKEN string // the Google/gogithub lib needs an PAT to access the GitHub API -// var K8S_IO_ORG = "kubernetes" //the owner or organization for the k8s.io repo -var K8S_IO_ORG = "strongjz" //the owner or organization for the k8s.io repo +var INGRESS_ORG = "strongjz" // the owner so we can test from forks +var INGRESS_REPO = "ingress-nginx" // the repo to pull from +var RELEASE_BRANCH = "main" //we only release from main +var GITHUB_TOKEN string // the Google/gogithub lib needs an PAT to access the GitHub API var K8S_IO_REPO = "k8s.io" //the repo that holds the images yaml for production promotion var INGRESS_REGISTRY = "registry.k8s.io" //Container registry for storage Ingress-nginx images var KUSTOMIZE_INSTALL_VERSION = "sigs.k8s.io/kustomize/kustomize/v4@v4.5.4" //static deploys needs kustomize to generate the template // ingress-nginx releases start with a TAG then a cloudbuild, then a promotion through a PR, this the location of that PR -var IMAGES_YAML = "https://raw.githubusercontent.com/strongjz/k8s.io/main/registry.k8s.io/images/k8s-staging-ingress-nginx/images.yaml" +var IMAGES_YAML = "https://raw.githubusercontent.com/" + INGRESS_ORG + "/k8s.io/main/registry.k8s.io/images/k8s-staging-ingress-nginx/images.yaml" var ctx = context.Background() // Context used for GitHub Client +var version string + const INDEX_DOCS = "docs/deploy/index.md" //index.md has a version of the controller and needs to updated const CHANGELOG = "Changelog.md" //Name of the changelog @@ -78,7 +78,7 @@ var controllerReleaseCmd = &cobra.Command{ Short: "Release Ingress-nginx Controller", Long: "Release a new version of ingress-nginx controller", Run: func(cmd *cobra.Command, args []string) { - + NewRelease(version) }, } @@ -86,7 +86,7 @@ func init() { rootCmd.AddCommand(releaseCmd) releaseCmd.AddCommand(helmReleaseCmd) releaseCmd.AddCommand(controllerReleaseCmd) - + controllerReleaseCmd.Flags().StringVar(&version, "version", "v1.0.0-dev", "version of the controller to update") } // ControllerImage - struct with info about controllers @@ -149,7 +149,7 @@ func NewRelease(version string) { tag, err := getIngressNGINXVersion() CheckIfError(err, "RELEASE Retrieving the current Ingress Nginx Version") - Info("RELEASE Checking Current Version %s to New Version %s", tag, version) + Info("RELEASE Checking Current Version %s to New Version %s", tag[1:], version) //if the version were upgrading does not match the TAG file, lets update the TAG file if tag[1:] != version { Warning("RELEASE Ingress Nginx TAG %s and new version %s do not match", tag, version) @@ -183,7 +183,7 @@ func NewRelease(version string) { } //update helm chart app version - //mg.Deps(mg.F(Helm.UpdateVersion, version)) + UpdateVersion(version) releaseNotes.NewHelmChartVersion = currentChartVersion() diff --git a/ingressctl/cmd/tags.go b/ingressctl/cmd/tags.go index f2cae36d6..63b5acd8c 100644 --- a/ingressctl/cmd/tags.go +++ b/ingressctl/cmd/tags.go @@ -97,6 +97,15 @@ func BumpNginx(newTag string) { currentTag, err := getIngressNGINXVersion() CheckIfError(err, "Getting Ingress-nginx Version") bump(currentTag, newTag) + + if !checkSemVer(currentTag, newTag) { + ErrorF("ERROR: Semver is not valid %v", newTag) + os.Exit(1) + } + + Info("Updating Tag %v to %v", currentTag, newTag) + err = os.WriteFile("../TAG", []byte(newTag), 0666) + CheckIfError(err, "Error Writing New Tag File") } func bump(currentTag, newTag string) { @@ -107,7 +116,7 @@ func bump(currentTag, newTag string) { } Info("Updating Tag %v to %v", currentTag, newTag) - err := os.WriteFile("../TAG", []byte(newTag), 0666) + err := os.WriteFile("TAG", []byte(newTag), 0666) CheckIfError(err, "Error Writing New Tag File") }