Skip to content

Release Charts

Release Charts #58

Workflow file for this run

name: Release Charts
on:
push:
branches: [master]
paths:
- charts/**
workflow_dispatch:
jobs:
release_charts:
permissions:
contents: write # to push chart release and create a release (helm/chart-releaser-action)
runs-on: ubuntu-latest
outputs:
changed_charts: ${{ steps.chart-releaser.outputs.changed_charts }}
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Fetch history
run: git fetch --prune --unshallow
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
with:
version: v3.12.0
- name: Add dependency chart repos
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
- name: Run chart-releaser
id: chart-releaser
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: true
generate_release_notes:
runs-on: ubuntu-latest
needs: release_charts
if: needs.release_charts.outputs.changed_charts
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.2
with:
fetch-depth: 0
- name: Generate release notes for the released charts
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
released_charts_paths="${{ needs.release_charts.outputs.changed_charts }}"
echo "Released charts: ${released_charts}"
# Generate release notes for each chart.
for chart_path in ${released_charts_paths}; do
chart_name=$(echo "$chart_path" | cut -d'/' -f2)
# Fetch latest and previous tag
tags=($(git tag --list "${chart_name}-[0-9]*.[0-9]*.[0-9]*" | sort -r | head -n 2))
latest_tag="${tags[0]}"
previous_tag="${tags[1]}"
if [[ ! -z $latest_tag ]] && [[ ! -z $previous_tag ]] && [ "$latest_tag" != "$previous_tag" ]; then
echo "Latest or previous tag are either empty or are the same for chart $chart_name"
exit 1
else
# Get release notes for chart
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository_owner }}/${{ github.repository }}/releases/generate-notes \
-f tag_name='${latest_tag}' \
-f target_commitish='master' \
-f previous_tag_name='${previous_tag}' | jq -r '.body' > $chart_path/RELEASE_NOTES.md
# Update release notes for the chart release
gh release edit hivemq-platform-operator-0.3.0 --notes-file $chart_path/RELEASE_NOTES.md
fi
done