Files
sure/.github/workflows/chart-release.yml
Juan José Mata 69fa440558 Refactor GitHub Actions workflows (#1023)
* Unify release workflows and add chart/mobile wrappers

* Update chart CI to kube 1.25

* Fetch tagged commit before pushing release branch

* Old `azure/setup-helm`

* Base chart dispatch version on existing chart tags

* `grep` failure with `pipefail` bypasses the user-friendly error message

* `gh-pages` push lacks retry logic

* Auto-incremented chart tag collision

* `grep -Ev` pipeline will crash

* Missed one
2026-02-19 21:36:47 +01:00

111 lines
3.8 KiB
YAML

name: Chart Release
on:
push:
tags:
- 'chart-v*'
workflow_dispatch:
permissions:
contents: write
jobs:
prepare_release:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag.outputs.tag_name }}
chart_version: ${{ steps.tag.outputs.chart_version }}
app_version: ${{ steps.tag.outputs.app_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve chart release tag
id: tag
shell: bash
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
BASE_STABLE_TAG="$(git tag --list 'v*' --sort=-v:refname | { grep -Ev 'alpha|beta|rc' || true; } | head -n 1)"
if [ -z "$BASE_STABLE_TAG" ]; then
echo "::error::No stable app tag found for chart appVersion"
exit 1
fi
LATEST_CHART_TAG="$(git tag --list 'chart-v*' --sort=-v:refname | head -n 1)"
if [ -n "$LATEST_CHART_TAG" ]; then
BASE_CHART_VERSION="${LATEST_CHART_TAG#chart-v}"
else
BASE_CHART_VERSION="$(sed -n 's/^version: //p' charts/sure/Chart.yaml | head -n 1)"
BASE_CHART_VERSION="${BASE_CHART_VERSION:-0.0.0}"
fi
MAJOR="$(echo "$BASE_CHART_VERSION" | cut -d. -f1)"
MINOR="$(echo "$BASE_CHART_VERSION" | cut -d. -f2)"
PATCH="$(echo "$BASE_CHART_VERSION" | cut -d. -f3 | sed 's/[^0-9].*$//')"
PATCH="${PATCH:-0}"
NEXT_PATCH=$((PATCH + 1))
TAG_NAME="chart-v${MAJOR}.${MINOR}.${NEXT_PATCH}"
while git rev-parse "refs/tags/${TAG_NAME}" >/dev/null 2>&1; do
NEXT_PATCH=$((NEXT_PATCH + 1))
TAG_NAME="chart-v${MAJOR}.${MINOR}.${NEXT_PATCH}"
done
CHART_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
if ! git tag "$TAG_NAME"; then
echo "::error::Failed to create tag ${TAG_NAME}"
exit 1
fi
if ! git push origin "$TAG_NAME"; then
echo "::error::Failed to push tag ${TAG_NAME} to origin"
exit 1
fi
else
TAG_NAME="${GITHUB_REF_NAME}"
BASE_STABLE_TAG="$(git tag --list 'v*' --sort=-v:refname | grep -Ev 'alpha|beta|rc' | head -n 1 || true)"
fi
CHART_VERSION="${TAG_NAME#chart-v}"
if [ -z "${BASE_STABLE_TAG:-}" ]; then
echo "::warning::No stable app tag found; falling back to CHART_VERSION (${CHART_VERSION}) for appVersion"
fi
APP_VERSION="${BASE_STABLE_TAG:-${CHART_VERSION}}"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT"
echo "app_version=$APP_VERSION" >> "$GITHUB_OUTPUT"
publish_chart:
needs: prepare_release
uses: ./.github/workflows/helm-publish.yml
with:
chart_version: ${{ needs.prepare_release.outputs.chart_version }}
app_version: ${{ needs.prepare_release.outputs.app_version }}
update_gh_pages: true
secrets: inherit
release:
needs: [prepare_release, publish_chart]
runs-on: ubuntu-latest
steps:
- name: Download Helm chart artifact
uses: actions/download-artifact@v4
with:
name: helm-chart-package
path: ${{ runner.temp }}/helm-artifacts
- name: Create chart GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare_release.outputs.tag_name }}
name: ${{ needs.prepare_release.outputs.tag_name }}
generate_release_notes: true
files: ${{ runner.temp }}/helm-artifacts/*.tgz