Skip to content

Commit

Permalink
Merge branch 'main' into TT-13588/tyk_api_port
Browse files Browse the repository at this point in the history
  • Loading branch information
komalsukhani authored Dec 17, 2024
2 parents c4a9014 + 0dabe87 commit 82dbc09
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 1 deletion.
110 changes: 110 additions & 0 deletions .github/workflows/release-alpha.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
api-key: ${{ secrets.CLOUDSMITH_API_KEY }}
command: "push"
format: "helm"
owner: "tyk"
repo: "helm"
file: "${{ steps.file-name.outputs.fileName }}"
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ jobs:
format: "helm"
owner: "tyk"
repo: "helm"
file: "${{ steps.file-name.outputs.fileName }}"
file: "${{ steps.file-name.outputs.fileName }}"

0 comments on commit 82dbc09

Please sign in to comment.