chart: show the newest chart in the Charts repository README
CI / chart (push) Successful in 2s
CI / chart-push (push) Successful in 4s
CI / test (push) Successful in 1m39s
CI / image (push) Successful in 3m31s

The chart repository README was static, so the published version was only
visible in index.yaml. push-chart.sh now regenerates a marked "Newest chart"
section with the version, app version, publish time and source commit, plus a
table of the newest version of every chart in the repository. Plain markdown
only, so the README stays readable on the Gitea front page.

The section is inserted before the first section on the first publish and
replaced in place afterwards.
This commit is contained in:
TapTap committed 2026-11-14 21:59:51 +00:00
1 parent 8e87fed93f
commit f1dc60aae5
2 files changed
+89

No files matched your search

+4
View File
@@ -259,6 +259,10 @@ Image: gitea.tap-tap.win/taptap/audiomanager:<tag>
Chart: https://gitea.tap-tap.win/TapTap/Charts/raw/branch/main Chart: https://gitea.tap-tap.win/TapTap/Charts/raw/branch/main
``` ```
The [Charts README](https://gitea.tap-tap.win/TapTap/Charts) always shows the
newest published chart version; `scripts/push-chart.sh` regenerates that section
on every publish.
Kustomize example: Kustomize example:
+85
View File
@@ -99,6 +99,91 @@ fi
helm package "$CHART_DIR" --version "$VERSION" --destination "$workdir/repo" helm package "$CHART_DIR" --version "$VERSION" --destination "$workdir/repo"
helm repo index "$workdir/repo" --url "$CHARTS_RAW_URL" helm repo index "$workdir/repo" --url "$CHARTS_RAW_URL"
# Keep the repository README pointing at the newest version of every chart so
# the published version is visible without reading index.yaml.
app_version="$(awk '/^appVersion:/ { print $2; exit }' "$CHART_DIR/Chart.yaml" | tr -d '"')"
source_sha="${GITHUB_SHA:-$(git -C "$ROOT" rev-parse HEAD)}"
source_repo="${GITHUB_REPOSITORY:-TapTap/AudioManager}"
source_server="${GITHUB_SERVER_URL:-https://gitea.tap-tap.win}"
published_at="$(date -u '+%Y-%m-%d %H:%M UTC')"
newest_charts="$(
for archive in "$workdir/repo"/*.tgz; do
[[ -f "$archive" ]] || continue
helm show chart "$archive" 2>/dev/null \
| awk '
/^name:/ { name = $2 }
/^version:/ { version = $2 }
/^appVersion:/ { app = $2; gsub(/"/, "", app) }
END { if (name != "") printf "%s|%s|%s\n", name, version, app }
'
done | sort -t '|' -k1,1 -k2,2V \
| awk -F '|' '
{ if ($1 == last) { row = $0 } else { if (last != "") print row; last = $1; row = $0 } }
END { if (last != "") print row }
'
)"
section="$workdir/newest-chart.md"
{
echo '<!-- newest-chart:begin -->'
echo '## Newest chart'
echo
echo "\`$chart_name\` **$VERSION** (app \`$app_version\`), published $published_at"
echo "from commit [\`${source_sha:0:7}\`]($source_server/$source_repo/commit/$source_sha)."
echo
echo '| Chart | Newest version | App version |'
echo '| --- | --- | --- |'
while IFS='|' read -r name version app; do
[[ -n "$name" ]] || continue
echo "| \`$name\` | \`$version\` | ${app:--} |"
done <<< "$newest_charts"
echo '<!-- newest-chart:end -->'
} > "$section"
readme="$workdir/repo/README.md"
updated_readme="$workdir/repo/README.md.new"
if [[ -f "$readme" ]] && grep -q '<!-- newest-chart:begin -->' "$readme"; then
awk -v section="$section" '
/<!-- newest-chart:begin -->/ {
while ((getline line < section) > 0) print line
skipping = 1
next
}
/<!-- newest-chart:end -->/ { skipping = 0; next }
!skipping { print }
' "$readme" > "$updated_readme"
else
# No generated section yet: put it before the first "## " heading.
{
if [[ -f "$readme" ]]; then
awk -v section="$section" '
!inserted && /^## / {
while ((getline line < section) > 0) print line
print ""
inserted = 1
}
{ print }
END {
if (!inserted) {
print ""
while ((getline line < section) > 0) print line
}
}
' "$readme"
else
{
echo '# Charts'
echo
echo 'Published Helm chart repository for TapTap projects.'
echo
}
cat "$section"
fi
} > "$updated_readme"
fi
mv "$updated_readme" "$readme"
git -C "$workdir/repo" add . git -C "$workdir/repo" add .
if git -C "$workdir/repo" diff --cached --quiet; then if git -C "$workdir/repo" diff --cached --quiet; then
echo "Chart $(basename "$CHART_DIR") $VERSION is already published." echo "Chart $(basename "$CHART_DIR") $VERSION is already published."