Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TT-13635 (ci): add workflow for alpha Helm chart releases #371

Merged
merged 7 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]+"
komalsukhani marked this conversation as resolved.
Show resolved Hide resolved

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 }}"
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 }}"
Loading