From 2e5230f00c2af1960456bc2f23dfbbbd2107edef Mon Sep 17 00:00:00 2001 From: Glen Johnson Date: Tue, 20 Feb 2024 09:07:48 -0700 Subject: [PATCH] CNJR-3496: Remove hardcoded version updates for releases --- CONTRIBUTING.md | 22 +++++++--------------- Jenkinsfile | 9 +++++++++ bin/update_version | 13 +++++++++++++ helm/conjur-k8s-csi-provider/Chart.yaml | 4 ++-- pkg/provider/provider.go | 2 +- pkg/provider/provider_test.go | 9 +++++++-- 6 files changed, 39 insertions(+), 20 deletions(-) create mode 100755 bin/update_version diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 312af06..3de630e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,6 +46,9 @@ follow the instructions in this section. 1. Review the git log and ensure the [changelog](CHANGELOG.md) contains all relevant recent changes with references to GitHub issues or PRs, if possible. + Also ensure the latest unreleased version is accurate - our pipeline generates + a VERSION file based on the changelog, which is then used to assign the version + of the release and any release artifacts. 1. Review the changes since the last tag, and if the dependencies have changed revise the [NOTICES](NOTICES.txt) to correctly capture the included dependencies and their licenses / copyrights. @@ -53,15 +56,11 @@ follow the instructions in this section. written by TW, approved by PO/Engineer, and pushed to the forward-facing documentation. 1. Scan the project for vulnerabilities -### Update the version, changelog, and notices +### Release and Promote -1. Create a new branch for the version bump. -1. Based on the changelog content, determine the new version number. -1. Update this version in the following files: - 1. [provider.go](pkg/provider/provider.go) - 1. [Chart version](helm/conjur-k8s-csi-provider/Chart.yaml) -1. Commit these changes - `Bump version to x.y.z` is an acceptable commit - message - and open a PR for review. +1. Merging into main/master branches will automatically trigger a release. If successful, this release can be promoted at a later time. +1. Jenkins build parameters can be utilized to promote a successful release or manually trigger aditional releases as needed. +1. Reference the [internal automated release doc](https://github.com/conjurinc/docs/blob/master/reference/infrastructure/automated_releases.md#release-and-promotion-process) for releasing and promoting. ### Push Helm package @@ -70,10 +69,3 @@ follow the instructions in this section. 1. Move the Helm package file created in the previous step to the *docs* folder in the `helm-charts` repo. 1. Go to the `helm-charts` repo root folder and execute the `reindex.sh` script file located there. 1. Create a PR with those changes. - -### Release and Promote - -1. Merging into main/master branches will automatically trigger a release. If successful, this release can be promoted at a later time. -1. Jenkins build parameters can be utilized to promote a successful release or manually trigger aditional releases as needed. -1. Reference the [internal automated release doc](https://github.com/conjurinc/docs/blob/master/reference/infrastructure/automated_releases.md#release-and-promotion-process) for releasing and promoting. - diff --git a/Jenkinsfile b/Jenkinsfile index 7b8e6ca..298d474 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -85,6 +85,15 @@ pipeline { } } + // Updates the helm chart and Go module version based on the VERSION file + stage('Update Project versions') { + steps { + script { + infrapool.agentSh 'bin/update_version' + } + } + } + stage('Get latest upstream dependencies') { steps { script { diff --git a/bin/update_version b/bin/update_version new file mode 100755 index 0000000..9aa0e0f --- /dev/null +++ b/bin/update_version @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +version=$(cat VERSION) +provider_file="./pkg/provider/provider.go" +chart_yaml="./helm/conjur-k8s-csi-provider/Chart.yaml" + +# Update the providerVersion constant +sed -i "s/const providerVersion = \".*\"/const providerVersion = \"$version\"/" "$provider_file" + +# Update the chart version +sed -i "s/version: .*/version: $version/" "$chart_yaml" diff --git a/helm/conjur-k8s-csi-provider/Chart.yaml b/helm/conjur-k8s-csi-provider/Chart.yaml index e7a3d87..29e3152 100644 --- a/helm/conjur-k8s-csi-provider/Chart.yaml +++ b/helm/conjur-k8s-csi-provider/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 -description: A Helm chart for deploying CyberArk Conjur's CSI Driver Provider +description: A Helm chart for deploying CyberArk Conjur's CSI Driver Provider name: conjur-k8s-csi-provider -version: 0.1.0 +version: 0.0-dev home: https://github.com/cyberark/conjur-k8s-csi-provider icon: https://www.cyberark.com/wp-content/uploads/2015/12/cybr-aim.jpg diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 9b895b6..80eba5f 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -12,7 +12,7 @@ import ( ) const providerName = "conjur" -const providerVersion = "0.1.0" +const providerVersion = "0.0-dev" const saTokensKey = "csi.storage.k8s.io/serviceAccount.tokens" const configurationVersionKey = "conjur.org/configurationVersion" diff --git a/pkg/provider/provider_test.go b/pkg/provider/provider_test.go index 2e54c05..b4a3b49 100644 --- a/pkg/provider/provider_test.go +++ b/pkg/provider/provider_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "os" "testing" "github.com/cyberark/conjur-k8s-csi-provider/pkg/conjur" @@ -195,14 +196,18 @@ func TestVersion(t *testing.T) { }, }, { - description: "response includes hardcoded provider details", + description: "response includes provider details", req: &v1alpha1.VersionRequest{ Version: "0.0.test", }, assertions: func(t *testing.T, resp *v1alpha1.VersionResponse, err error) { assert.Nil(t, err) assert.Equal(t, "conjur", resp.RuntimeName) - assert.Equal(t, "0.1.0", resp.RuntimeVersion) + expectedVersion, err := os.ReadFile("/conjur-k8s-csi-provider/VERSION") + if err != nil { + expectedVersion = []byte("0.0-dev") + } + assert.Equal(t, string(expectedVersion), resp.RuntimeVersion) }, }, }