From 77a4e51e22f491f6f2beb864d191425dfd12e613 Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Fri, 30 Jun 2023 16:12:38 -0400 Subject: [PATCH 01/13] Extracts Chart.yaml and pulls version from it --- smoke-test/action.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index f3d9276..ce5ae5e 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -39,9 +39,26 @@ inputs: runs: using: "composite" steps: + - name: Extract Chart YAML + id: extract-chart-yaml + shell: bash + run: | + tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") + chart_yaml=$(tar -xzvf ${tarball} $(tar -tzf ${tarball} | grep Chart.yaml)) + echo "chart-yaml=${chart_yaml}" >> $GITHUB_OUTPUT + env: + YAML_DIR: ${{ inputs.yaml-dir }} + CHART_NAME: ${{ inputs.helm-chart-name }} + - name: Get Chart Version + id: get-chart-version + uses: mikefarah/yq@master + with: + cmd: yq '.version' ${{ steps.extract-chart-yaml.outputs.chart-yaml }} - name: Define App Version shell: bash - run: echo "APP_VERSION=0.0.1-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV + run: echo "APP_VERSION=${CHART_VERSION}-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV + env: + CHART_VERSION: ${{ steps.get-chart-version.outputs.results }} - name: Define Channel Name shell: bash run: echo "CHANNEL_NAME=${{ github.ref_name }}-${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}-${{ inputs.kubernetes-distribution }}-${{ inputs.kubernetes-version }}" >> $GITHUB_ENV @@ -124,4 +141,4 @@ runs: with: app-slug: ${{ inputs.app-slug }} api-token: ${{ inputs.api-token }} - channel-slug: ${{ steps.create-release.outputs.channel-slug }} \ No newline at end of file + channel-slug: ${{ steps.create-release.outputs.channel-slug }} From 5037334080558a4e2afd7526f55ba3a41bc6cf10 Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Fri, 30 Jun 2023 16:25:49 -0400 Subject: [PATCH 02/13] Switches output to env variable for Chart.yaml --- smoke-test/action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index ce5ae5e..bc0b112 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -45,7 +45,7 @@ runs: run: | tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") chart_yaml=$(tar -xzvf ${tarball} $(tar -tzf ${tarball} | grep Chart.yaml)) - echo "chart-yaml=${chart_yaml}" >> $GITHUB_OUTPUT + echo "CHART_YAML=${chart_yaml}" >> $GITHUB_ENV env: YAML_DIR: ${{ inputs.yaml-dir }} CHART_NAME: ${{ inputs.helm-chart-name }} @@ -53,7 +53,9 @@ runs: id: get-chart-version uses: mikefarah/yq@master with: - cmd: yq '.version' ${{ steps.extract-chart-yaml.outputs.chart-yaml }} + cmd: yq '.version' ${CHART_YAML} + env: + CHART_YAML: ${{ env.CHART_YAML }} - name: Define App Version shell: bash run: echo "APP_VERSION=${CHART_VERSION}-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV From b5289bc29985af120c38ac462079c9a17e714763 Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Fri, 30 Jun 2023 16:42:21 -0400 Subject: [PATCH 03/13] Avoids Chart yaml from dependencies --- smoke-test/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index bc0b112..fd26d14 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -44,7 +44,7 @@ runs: shell: bash run: | tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") - chart_yaml=$(tar -xzvf ${tarball} $(tar -tzf ${tarball} | grep Chart.yaml)) + chart_yaml=$(tar -xzvf ${tarball} $(tar -tzf ${tarball} --exclude "*/charts/*" | grep Chart.yaml)) echo "CHART_YAML=${chart_yaml}" >> $GITHUB_ENV env: YAML_DIR: ${{ inputs.yaml-dir }} From d4cd8bbcfb00fe94443a0b2bc4fddec3f90780f7 Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Fri, 30 Jun 2023 16:46:06 -0400 Subject: [PATCH 04/13] Corrects YQ output reference --- smoke-test/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index fd26d14..9b90ab1 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -60,7 +60,7 @@ runs: shell: bash run: echo "APP_VERSION=${CHART_VERSION}-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV env: - CHART_VERSION: ${{ steps.get-chart-version.outputs.results }} + CHART_VERSION: ${{ steps.get-chart-version.outputs.result }} - name: Define Channel Name shell: bash run: echo "CHANNEL_NAME=${{ github.ref_name }}-${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}-${{ inputs.kubernetes-distribution }}-${{ inputs.kubernetes-version }}" >> $GITHUB_ENV From 6f10dca778dbb8fae4e629eb7ee7a878e4638b04 Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Fri, 30 Jun 2023 16:52:26 -0400 Subject: [PATCH 05/13] Removes unneeded environment setup --- smoke-test/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 9b90ab1..6ca8524 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -54,8 +54,6 @@ runs: uses: mikefarah/yq@master with: cmd: yq '.version' ${CHART_YAML} - env: - CHART_YAML: ${{ env.CHART_YAML }} - name: Define App Version shell: bash run: echo "APP_VERSION=${CHART_VERSION}-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV From b0d38d283119fe73394b68af6fdc69b92c74504c Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Fri, 30 Jun 2023 17:09:14 -0400 Subject: [PATCH 06/13] Updates chart version --- smoke-test/action.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 6ca8524..978287f 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -62,6 +62,17 @@ runs: - name: Define Channel Name shell: bash run: echo "CHANNEL_NAME=${{ github.ref_name }}-${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}-${{ inputs.kubernetes-distribution }}-${{ inputs.kubernetes-version }}" >> $GITHUB_ENV + - name: Update Chart YAML + id: update-chart-yaml + uses: mikefarah/yq@master + with: + cmd: yq '.version = "${APP_VERSION}"' ${CHART_YAML} + - name: Update Chart Version + id: update-chart-version + shell: bash + run: | + tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") + tar -uzvf ${tarball} ${CHART_YAML} - name: 'Create Release' id: 'create-release' uses: replicatedhq/compatibility-actions/create-release@v0 From f63904b1bc3fda0e8241825674c941d0a52b8634 Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Fri, 30 Jun 2023 17:22:25 -0400 Subject: [PATCH 07/13] Updates version within the chart --- smoke-test/action.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 978287f..57c4db7 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -66,13 +66,18 @@ runs: id: update-chart-yaml uses: mikefarah/yq@master with: - cmd: yq '.version = "${APP_VERSION}"' ${CHART_YAML} + cmd: yq -i '.version = "${{ env.APP_VERSION }}"' ${CHART_YAML} - name: Update Chart Version id: update-chart-version shell: bash run: | tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") - tar -uzvf ${tarball} ${CHART_YAML} + gunzip ${tarball} + tar -uvf ${tarball%tgz}.tar ${CHART_YAML} + gzip ${tarball%tgz}.tar + mv ${tarball%tgz}.tar.gz ${tarball} + env: + YAML_DIR: ${{ inputs.yaml-dir }} - name: 'Create Release' id: 'create-release' uses: replicatedhq/compatibility-actions/create-release@v0 From 1f910a05cb03efb6ce5f8d66c3be5a4f099ae7c7 Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Sun, 2 Jul 2023 08:10:15 -0400 Subject: [PATCH 08/13] Simplifies repackaging --- smoke-test/action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 57c4db7..1aefc60 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -72,10 +72,10 @@ runs: shell: bash run: | tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") - gunzip ${tarball} - tar -uvf ${tarball%tgz}.tar ${CHART_YAML} - gzip ${tarball%tgz}.tar - mv ${tarball%tgz}.tar.gz ${tarball} + tar -xvf ${tarball%tgz} -C /tmp/repack + helm package --version "${{ env.APP_VERSION }}" /tmp/repack + mv /tmp/repack/${{ inputs.helm-chart-name }}-${{env.APP_VERSION }}.tgz $(dirname ${tarball }) + rm ${tarball} env: YAML_DIR: ${{ inputs.yaml-dir }} - name: 'Create Release' From 6d32cf5f6f1b14b4d783ab7432d796590dd70f8a Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Sun, 2 Jul 2023 08:31:22 -0400 Subject: [PATCH 09/13] Updates chart only when installing with Helm --- smoke-test/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 1aefc60..59dcf33 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -70,7 +70,9 @@ runs: - name: Update Chart Version id: update-chart-version shell: bash + if: ${{ inputs.installation-method == 'helm' }} run: | + # update the chart version to match the Replicated app version tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") tar -xvf ${tarball%tgz} -C /tmp/repack helm package --version "${{ env.APP_VERSION }}" /tmp/repack From bf9367906d975ff59c0259a64bb8d5c5e627327b Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Sun, 2 Jul 2023 08:33:21 -0400 Subject: [PATCH 10/13] Swtiches decoration from prerelease version to build metadata --- smoke-test/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 59dcf33..47ec634 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -56,7 +56,7 @@ runs: cmd: yq '.version' ${CHART_YAML} - name: Define App Version shell: bash - run: echo "APP_VERSION=${CHART_VERSION}-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV + run: echo "APP_VERSION=${CHART_VERSION}+${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV env: CHART_VERSION: ${{ steps.get-chart-version.outputs.result }} - name: Define Channel Name From 49634779643bd4db895627cfc3956e8082c27eaa Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Sun, 2 Jul 2023 08:39:49 -0400 Subject: [PATCH 11/13] Debugs repackaging --- smoke-test/action.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 47ec634..24cfdce 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -74,9 +74,10 @@ runs: run: | # update the chart version to match the Replicated app version tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") - tar -xvf ${tarball%tgz} -C /tmp/repack - helm package --version "${{ env.APP_VERSION }}" /tmp/repack - mv /tmp/repack/${{ inputs.helm-chart-name }}-${{env.APP_VERSION }}.tgz $(dirname ${tarball }) + mkdir -p /tmp/repack + tar -xf ${tarball} -C /tmp/repack + helm package --version "${{ env.APP_VERSION }}" /tmp/repack/${CHART_NAME}* + mv ${{ inputs.helm-chart-name }}-${{env.APP_VERSION }}.tgz $(dirname ${tarball}) rm ${tarball} env: YAML_DIR: ${{ inputs.yaml-dir }} From 700ac60f6f9ed1555c539ccba8578f7a836d041f Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Sun, 2 Jul 2023 09:15:01 -0400 Subject: [PATCH 12/13] Allows for explicit version --- smoke-test/action.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 24cfdce..25d1d0c 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -13,6 +13,9 @@ inputs: description: 'The directory containing multiple yamls for a Replicated release.' required: true default: 'manifests' + version: + description: 'Provides version to use for the Replicated Release' + reqired: false kubernetes-distribution: description: 'Kubernetes distribution of the cluster to provision.' required: true @@ -41,6 +44,7 @@ runs: steps: - name: Extract Chart YAML id: extract-chart-yaml + if: inputs.version == '' shell: bash run: | tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") @@ -51,27 +55,36 @@ runs: CHART_NAME: ${{ inputs.helm-chart-name }} - name: Get Chart Version id: get-chart-version + if: inputs.version == '' uses: mikefarah/yq@master with: cmd: yq '.version' ${CHART_YAML} - name: Define App Version shell: bash + if: inputs.version == '' run: echo "APP_VERSION=${CHART_VERSION}+${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV env: CHART_VERSION: ${{ steps.get-chart-version.outputs.result }} + - name: Use Explicit Version + shell: bash + if: inputs.version != '' + run: echo "APP_VERSION=${VERSION}" >> $GITHUB_ENV + env: + VERSION: ${{ inputs.version }} - name: Define Channel Name shell: bash run: echo "CHANNEL_NAME=${{ github.ref_name }}-${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}-${{ inputs.kubernetes-distribution }}-${{ inputs.kubernetes-version }}" >> $GITHUB_ENV - name: Update Chart YAML id: update-chart-yaml + if: inputs.version == '' uses: mikefarah/yq@master with: cmd: yq -i '.version = "${{ env.APP_VERSION }}"' ${CHART_YAML} - name: Update Chart Version id: update-chart-version shell: bash - if: ${{ inputs.installation-method == 'helm' }} - run: | + if: inputs.installation-method == 'helm' && inputs.version == '' + run: | # update the chart version to match the Replicated app version tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") mkdir -p /tmp/repack @@ -81,6 +94,7 @@ runs: rm ${tarball} env: YAML_DIR: ${{ inputs.yaml-dir }} + CHART_NAME: ${{ inputs.helm-chart-name }} - name: 'Create Release' id: 'create-release' uses: replicatedhq/compatibility-actions/create-release@v0 From 72513417542f5229469fb47c30e751a697781a58 Mon Sep 17 00:00:00 2001 From: Chuck D'Antonio Date: Tue, 11 Jul 2023 13:37:52 -0400 Subject: [PATCH 13/13] Reponds to @jdewinne review --- smoke-test/action.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/smoke-test/action.yml b/smoke-test/action.yml index 25d1d0c..f224a7a 100644 --- a/smoke-test/action.yml +++ b/smoke-test/action.yml @@ -15,7 +15,7 @@ inputs: default: 'manifests' version: description: 'Provides version to use for the Replicated Release' - reqired: false + required: false kubernetes-distribution: description: 'Kubernetes distribution of the cluster to provision.' required: true @@ -44,7 +44,7 @@ runs: steps: - name: Extract Chart YAML id: extract-chart-yaml - if: inputs.version == '' + if: inputs.installation-method == 'helm' && inputs.version == '' shell: bash run: | tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") @@ -55,16 +55,23 @@ runs: CHART_NAME: ${{ inputs.helm-chart-name }} - name: Get Chart Version id: get-chart-version - if: inputs.version == '' + if: inputs.installation-method == 'helm' && inputs.version == '' uses: mikefarah/yq@master with: cmd: yq '.version' ${CHART_YAML} - name: Define App Version shell: bash - if: inputs.version == '' + if: inputs.installation-method == 'helm' && inputs.version == '' run: echo "APP_VERSION=${CHART_VERSION}+${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV env: CHART_VERSION: ${{ steps.get-chart-version.outputs.result }} + # there no good default here, going back to what Josh had since it's specific to the channel and the channel goes away + - name: Define App Version + shell: bash + if: inputs.installation-method == 'kots' && inputs.version == '' + run: echo "APP_VERSION=0.1.0+${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV + env: + CHART_VERSION: ${{ steps.get-chart-version.outputs.result }} - name: Use Explicit Version shell: bash if: inputs.version != ''