diff --git a/.github/workflows/release-alpha.yaml b/.github/workflows/release-alpha.yaml new file mode 100644 index 00000000..509f299a --- /dev/null +++ b/.github/workflows/release-alpha.yaml @@ -0,0 +1,110 @@ +name: Helm Charts Release Alpha Version + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" + +jobs: + prepare-release: + runs-on: ubuntu-latest + outputs: + charts: ${{ steps.find-charts.outputs.charts }} + version: ${{ steps.extract-version.outputs.version }} + steps: + - uses: actions/checkout@v4 + + - name: Extract version + id: extract-version + run: | + VERSION=${GITHUB_REF#refs/tags/v} + echo "version=${VERSION}" >> $GITHUB_OUTPUT + + - name: Find charts to release + id: find-charts + run: | + CHARTS=$(find . -type f -name Chart.yaml -not -path "*/components/tyk-operator/*" -exec dirname {} \; | jq -R . | jq -sc .) + echo "charts=${CHARTS}" >> $GITHUB_OUTPUT + + - name: Update Chart.yaml of each chart + run: | + for chart_dir in $(find . -type f -name Chart.yaml -not -path "*/components/tyk-operator/*" -exec dirname {} \;); do + chart_file_path="$chart_dir/Chart.yaml" + echo " --> updating: $chart_dir $chart_file_path" + yq eval ' + .version = "${{ steps.extract-version.outputs.version }}" | + .annotations["artifacthub.io/prerelease"] = "true" + ' -i $chart_file_path + + if [[ "$chart_dir" != "./components"* ]]; then + echo " --> umbrella chart dependencies update $chart_dir $chart_file_path" + + num_deps=$(yq eval '.dependencies | length' "${chart_file_path}") + echo " --> umbrella chart dependencies count: $num_deps" + if [ "${num_deps}" -gt 0 ]; then + charts=${{ steps.find-charts.outputs.charts }} + echo "$charts" + + for i in $(seq 0 $((num_deps - 1))); do + dep_name=$(yq eval ".dependencies[$i].name" "${chart_file_path}") || continue + echo " --> umbrella chart dependency check: $dep_name" + if [[ "${dep_name}" =~ "tyk" ]] && [ "${dep_name}" != "tyk-operator" ]; then + echo " --> update dependency $dep_name version to ${{ steps.extract-version.outputs.version }}" + yq eval ".dependencies[$i].version = \"${{ steps.extract-version.outputs.version }}\"" -i "${chart_file_path}" + fi + done + fi + fi + + echo " --> cat $chart_dir $chart_file_path" + cat $chart_file_path + done + + - name: Upload modified charts + uses: actions/upload-artifact@v4 + with: + name: charts + path: "./**" + + release-alpha-version: + needs: prepare-release + runs-on: ubuntu-latest + strategy: + matrix: + chart: ${{ fromJson(needs.prepare-release.outputs.charts) }} + steps: + - name: Download modified charts + uses: actions/download-artifact@v4 + with: + name: charts + path: "./" + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: "v3.16.0" + + - name: Update Helm Dependencies + run: | + helm repo add tyk-helm https://helm.tyk.io/public/helm/charts/ + helm dependency update ${{ matrix.chart }} + + - name: Package Helm Chart + run: | + helm package ${{ matrix.chart }} --version ${{ needs.prepare-release.outputs.version }} + + - name: Helm Chart package file name + id: file-name + run: | + echo "fileName=$(basename ${{ matrix.chart }})-${{ needs.prepare-release.outputs.version }}.tgz" + echo "fileName=$(basename ${{ matrix.chart }})-${{ needs.prepare-release.outputs.version }}.tgz" >> "$GITHUB_OUTPUT" + + - name: Push Helm Chart to Cloudsmith + uses: cloudsmith-io/action@v0.5.2 + with: + api-key: ${{ secrets.CLOUDSMITH_API_KEY }} + command: "push" + format: "helm" + owner: "tyk" + repo: "helm" + file: "${{ steps.file-name.outputs.fileName }}" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a14b0faf..fe142629 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -83,4 +83,4 @@ jobs: format: "helm" owner: "tyk" repo: "helm" - file: "${{ steps.file-name.outputs.fileName }}" \ No newline at end of file + file: "${{ steps.file-name.outputs.fileName }}"