From 98cc421cc7f7b3693f53c94d35ad8f7366a79f70 Mon Sep 17 00:00:00 2001
From: Marc Burnie <mburnie@amazon.com>
Date: Tue, 6 Sep 2022 21:50:03 +0000
Subject: [PATCH] Versioning helm chart

commit cfb9c950
Author: Marc Burnie <mburnie@amazon.com>
Date: Tue Aug 30 2022 07:38:26 GMT-0500 (Central Daylight Time)

    muting wget


commit a9f1d9f9
Author: Marc Burnie <mburnie@amazon.com>
Date: Mon Aug 29 2022 14:47:20 GMT-0500 (Central Daylight Time)

    adding versioning helm chart
---
 devops/aws/chart/Chart.yaml                     |  2 +-
 provider/partition-aws/build-aws/buildspec.yaml | 10 ++++------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/devops/aws/chart/Chart.yaml b/devops/aws/chart/Chart.yaml
index 92d0a190d..b96b823b8 100644
--- a/devops/aws/chart/Chart.yaml
+++ b/devops/aws/chart/Chart.yaml
@@ -1,6 +1,6 @@
 apiVersion: v2
 name: os-partition
-version: 0.1.0
+version:
 kubeVersion: "v1.21.x-x-x"
 description: Partitions Helm chart for Kubernetes
 type: application
diff --git a/provider/partition-aws/build-aws/buildspec.yaml b/provider/partition-aws/build-aws/buildspec.yaml
index ea8d6a608..ba28b3c85 100644
--- a/provider/partition-aws/build-aws/buildspec.yaml
+++ b/provider/partition-aws/build-aws/buildspec.yaml
@@ -41,6 +41,7 @@ phases:
       - mvn -version
       - mkdir -p /root/.m2
       - cp ./provider/partition-aws/maven/settings.xml /root/.m2/settings.xml # copy the AWS-specific settings.xml to the CodeBuild instance's .m2 folder
+      - wget https://github.com/mikefarah/yq/releases/download/v4.27.2/yq_linux_amd64 -q -O /usr/bin/yq && chmod +x /usr/bin/yq
       - export AWS_ACCOUNT_ID=`aws sts get-caller-identity | grep Account | cut -d':' -f 2 | cut -d'"' -f 2`
       - export AWS_OSDU_DEV_MAVEN_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain $AWS_OSDU_DEV_MAVEN_DOMAIN --domain-owner $AWS_ACCOUNT_ID --query authorizationToken --output text`
   pre_build:
@@ -60,6 +61,8 @@ phases:
       - mkdir -p ${OUTPUT_DIR}/bin
       - mkdir -p ${OUTPUT_DIR}/testing && mkdir -p ${INTEGRATION_TEST_OUTPUT}  && mkdir -p ${INTEGRATION_TEST_OUTPUT}/bin
       - echo "Placeholder" >> ${OUTPUT_DIR}/build-info.json # touched so that the output directory has some content incase the build fails so that testing reports are uploaded
+      - pom_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
+      - export VERSION=${pom_version%-*}
       - printenv
 
       - echo "Building primary service assemblies..."
@@ -68,15 +71,10 @@ phases:
       - echo "Building integration testing assemblies and gathering artifacts..."
       - ./testing/partition-test-aws/build-aws/prepare-dist.sh
 
-      # Push Helm charts to repo
-      # - cd devops/charts
-      # - for dir in */ ; do chart=$(echo ${dir} | sed 's:/*$::'); helm s3 init ${HELM_REPO}/${BRANCH_NAME}/${chart}; helm repo add --force-update ${chart} ${HELM_REPO}/${BRANCH_NAME}/${chart}; helm package ./${chart}; helm s3 push --force $(find . -name ${chart}'-*.tgz' -print | head -n 1) ${chart}; done
-      # - cd ../..
-
+      - yq -i '.version = strenv(VERSION)' devops/aws/chart/Chart.yaml
       - echo "--Copying Helm Charts to ${OUTPUT_DIR:-dist}--"
       - rsync -r devops/aws/* "${OUTPUT_DIR:-dist}"
 
-
       - echo "Logging into Docker Hub..."
       - docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
 
-- 
GitLab