diff --git a/smoke-test/action.yml b/smoke-test/action.yml index f3d9276..f224a7a 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' + required: false kubernetes-distribution: description: 'Kubernetes distribution of the cluster to provision.' required: true @@ -39,12 +42,66 @@ inputs: runs: using: "composite" steps: + - name: Extract Chart YAML + id: extract-chart-yaml + if: inputs.installation-method == 'helm' && inputs.version == '' + shell: bash + run: | + tarball=$(find ${YAML_DIR} -name "${CHART_NAME}*.tgz") + 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 }} + CHART_NAME: ${{ inputs.helm-chart-name }} + - name: Get Chart Version + id: get-chart-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.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 - run: echo "APP_VERSION=0.0.1-${GITHUB_REF_NAME//[^a-zA-Z0-9]/}.${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV + 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 != '' + 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' && 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 + 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 }} + CHART_NAME: ${{ inputs.helm-chart-name }} - name: 'Create Release' id: 'create-release' uses: replicatedhq/compatibility-actions/create-release@v0 @@ -124,4 +181,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 }}