simplify workflow #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 .) | |
# CHARTS="[\"./tyk-control-plane\"]" | |
echo "charts=${CHARTS}" >> $GITHUB_OUTPUT | |
- name: Update Chart.yaml of each chart | |
run: | | |
echo "STARTINGUPDATE2" | |
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 | |
echo " --> cat $chart_dir $chart_file_path" | |
cat $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 | |
echo " --> umbrella chart dependency file content $chart_file_path:" | |
cat $chart_file_path | |
done | |
fi | |
fi | |
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: 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 }}" |