From c25ed8a4285edfb58c61f8815d4127d139ff3f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Wed, 5 Jan 2022 19:51:34 +0100 Subject: [PATCH] [ci] Auto-generate chart changelogs based on Chart annotation (#1354) Auto-generate chart changelogs based on Chart annotation --- .github/ct-lint.yaml | 2 + .github/workflows/charts-lint-test.yaml | 14 +--- .github/workflows/charts-release.yaml | 81 ------------------ .github/workflows/generate-readme.yaml | 82 +++++++++++++++++++ .../generate-renovate-changelog.yaml | 41 ++++++---- charts/incubator/seafile/Chart.yaml | 18 +++- charts/incubator/seafile/README.md | 27 +++--- charts/incubator/seafile/README.md.gotmpl | 30 +++++++ .../seafile/README_CHANGELOG.md.gotmpl | 27 ------ hack/check-releasenotes.sh | 46 +++++++++++ hack/gen-helm-docs.sh | 4 - hack/renovate-releasenotes.sh | 48 +++++++++++ hack/templates/README.md.gotmpl | 30 +++++++ hack/templates/README_CHANGELOG.md.gotmpl | 27 ------ templates/chart/Chart.yaml | 8 +- templates/chart/README.md | 14 +--- templates/chart/README.md.gotmpl | 30 +++++++ templates/chart/README_CHANGELOG.md.gotmpl | 27 ------ 18 files changed, 335 insertions(+), 221 deletions(-) create mode 100644 .github/workflows/generate-readme.yaml delete mode 100644 charts/incubator/seafile/README_CHANGELOG.md.gotmpl create mode 100755 hack/check-releasenotes.sh create mode 100755 hack/renovate-releasenotes.sh delete mode 100644 hack/templates/README_CHANGELOG.md.gotmpl delete mode 100644 templates/chart/README_CHANGELOG.md.gotmpl diff --git a/.github/ct-lint.yaml b/.github/ct-lint.yaml index d096911c..9e8051d5 100644 --- a/.github/ct-lint.yaml +++ b/.github/ct-lint.yaml @@ -10,3 +10,5 @@ chart-repos: - k8s-at-home-libraries=https://library-charts.k8s-at-home.com - k8s-at-home=https://k8s-at-home.com/charts - jetstack=https://charts.jetstack.io +additional-commands: +- ./hack/check-releasenotes.sh {{ .Path }} diff --git a/.github/workflows/charts-lint-test.yaml b/.github/workflows/charts-lint-test.yaml index 6997fe6a..25ef4421 100644 --- a/.github/workflows/charts-lint-test.yaml +++ b/.github/workflows/charts-lint-test.yaml @@ -32,15 +32,10 @@ jobs: - name: Set up chart-testing uses: helm/chart-testing-action@v2.1.0 - - name: Install Dev tools - run: | - sudo wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O /usr/bin/yq - sudo chmod +x /usr/bin/yq - - name: Run chart-testing (list-changed) id: list-changed run: | - EXCLUDED=$(yq eval -j '.excluded-charts // []' .github/ct-lint.yaml) + EXCLUDED=$(yq eval -o=json '.excluded-charts // []' .github/ct-lint.yaml) CHARTS=$(ct list-changed --config .github/ct-lint.yaml) CHARTS_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]') OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED}, \"all\": ${CHARTS_JSON}}" | jq -c '.all-.excluded') @@ -67,15 +62,10 @@ jobs: - name: Set up chart-testing uses: helm/chart-testing-action@v2.1.0 - - name: Install Dev tools - run: | - sudo wget https://github.com/mikefarah/yq/releases/download/v4.2.0/yq_linux_amd64 -O /usr/bin/yq - sudo chmod +x /usr/bin/yq - - name: Run chart-testing (list-changed) id: list-changed run: | - EXCLUDED=$(yq eval -j '.excluded-charts // []' .github/ct-install.yaml) + EXCLUDED=$(yq eval -o=json '.excluded-charts // []' .github/ct-install.yaml) CHARTS=$(ct list-changed --config .github/ct-install.yaml) CHARTS_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]') OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED}, \"all\": ${CHARTS_JSON}}" | jq -c '.all-.excluded') diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 26629f56..a0901543 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -11,89 +11,8 @@ on: - 'charts/**' jobs: - generate-readme: - name: Auto-generate chart README - runs-on: ubuntu-20.04 - steps: - - name: Get k8s-at-home token - id: get-app-token - uses: getsentry/action-github-app-token@v1 - with: - app_id: ${{ secrets.K8S_AT_HOME_APP_ID }} - private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }} - - - name: Checkout - uses: actions/checkout@v2 - with: - token: ${{ steps.get-app-token.outputs.token }} - ref: master - - - uses: dorny/paths-filter@v2 - id: filter - with: - base: ${{ github.ref }} - list-files: shell - filters: | - addedOrModified: - - added|modified: 'charts/**' - - - name: Install Helm - if: steps.filter.outputs.addedOrModified == 'true' - uses: azure/setup-helm@v1 - with: - version: v3.6.3 - - - uses: actions/setup-python@v2 - if: steps.filter.outputs.addedOrModified == 'true' - with: - python-version: 3.7 - - - name: Install helm-docs - if: steps.filter.outputs.addedOrModified == 'true' - run: | - wget -O /tmp/helm-docs.deb https://github.com/norwoodj/helm-docs/releases/download/v1.5.0/helm-docs_1.5.0_linux_amd64.deb - sudo dpkg -i /tmp/helm-docs.deb - - - name: Run against changed charts - if: steps.filter.outputs.addedOrModified == 'true' - run: | - CHARTS=() - PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) - # Get only the chart paths - for i in "${PATHS[@]}" - do - IFS='/' read -r -a path_parts <<< "$i" - CHARTS+=("${path_parts[1]}/${path_parts[2]}") - done - - # Remove duplicates - CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` ) - - for i in "${CHARTS[@]}" - do - echo "Rendering README for chart ${i}" - IFS='/' read -r -a chart_parts <<< "$i" - if [ -f "charts/${chart_parts[0]}"/"${chart_parts[1]}/Chart.yaml" ]; then - ./hack/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}" - fi - echo "" - done - - - name: Create commit - if: steps.filter.outputs.addedOrModified == 'true' - uses: stefanzweifel/git-auto-commit-action@v4 - with: - push_options: --force - commit_message: Auto-generate chart README [no ci] - commit_user_name: k8s-at-home[bot] - commit_user_email: k8s-at-home[bot]@users.noreply.github.com - commit_author: k8s-at-home[bot] - file_pattern: charts/**/ - release: runs-on: ubuntu-20.04 - needs: - - generate-readme steps: - name: Get k8s-at-home token id: get-app-token diff --git a/.github/workflows/generate-readme.yaml b/.github/workflows/generate-readme.yaml new file mode 100644 index 00000000..16d42c55 --- /dev/null +++ b/.github/workflows/generate-readme.yaml @@ -0,0 +1,82 @@ +name: "Charts: Update Readme" + +concurrency: update-readme + +on: + workflow_dispatch: + pull_request: + paths: + - 'charts/**' + +jobs: + generate-readme: + name: Auto-generate chart README + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - uses: dorny/paths-filter@v2 + id: filter + with: + base: ${{ github.ref }} + list-files: shell + filters: | + addedOrModified: + - added|modified: 'charts/**' + + - name: Install Helm + if: steps.filter.outputs.addedOrModified == 'true' + uses: azure/setup-helm@v1 + with: + version: v3.6.3 + + - uses: actions/setup-python@v2 + if: steps.filter.outputs.addedOrModified == 'true' + with: + python-version: 3.9 + + - name: Install helm-docs + if: steps.filter.outputs.addedOrModified == 'true' + run: | + wget -O /tmp/helm-docs.deb https://github.com/k8s-at-home/helm-docs/releases/download/v0.1.1/helm-docs_0.1.1_Linux_x86_64.deb + sudo dpkg -i /tmp/helm-docs.deb + + - name: Run against changed charts + if: steps.filter.outputs.addedOrModified == 'true' + run: | + CHARTS=() + PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) + # Get only the chart paths + for i in "${PATHS[@]}" + do + IFS='/' read -r -a path_parts <<< "$i" + CHARTS+=("${path_parts[1]}/${path_parts[2]}") + done + + # Remove duplicates + CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` ) + + for i in "${CHARTS[@]}" + do + echo "Rendering README for chart ${i}" + IFS='/' read -r -a chart_parts <<< "$i" + if [ -f "charts/${chart_parts[0]}"/"${chart_parts[1]}/Chart.yaml" ]; then + ./hack/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}" + fi + echo "" + done + + - name: Create commit + if: steps.filter.outputs.addedOrModified == 'true' + uses: stefanzweifel/git-auto-commit-action@v4 + with: + push_options: --force + commit_message: Auto-generate chart README + + commit_user_name: ${{ github.actor }} + commit_user_email: ${{ github.actor }}@users.noreply.github.com + + file_pattern: charts/**/ diff --git a/.github/workflows/generate-renovate-changelog.yaml b/.github/workflows/generate-renovate-changelog.yaml index d7b7c333..a04d7e40 100644 --- a/.github/workflows/generate-renovate-changelog.yaml +++ b/.github/workflows/generate-renovate-changelog.yaml @@ -4,23 +4,37 @@ concurrency: update-renovate-pr-changelog on: pull_request: - branches: - - "test/**" + paths: + - "charts/**" jobs: + get-branch: + name: Get branch + runs-on: ubuntu-20.04 + outputs: + branch: ${{ steps.branch-name.outputs.current_branch }} + + steps: + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v5.1 + update-changelog: name: Update changelog runs-on: ubuntu-20.04 + needs: + - get-branch + if: startsWith(needs.get-branch.outputs.branch, 'renovate/') + steps: - name: Checkout uses: actions/checkout@v2 with: - fetch-depth: 2 + fetch-depth: 0 - uses: dorny/paths-filter@v2 id: filter with: - base: ${{ github.ref }} list-files: shell filters: | addedOrModified: @@ -49,17 +63,16 @@ jobs: ./hack/renovate-releasenotes.sh "charts/${chart_parts[0]}"/"${chart_parts[1]}" fi echo "" - cat "charts/${chart_parts[0]}"/"${chart_parts[1]}/Chart.yaml" done - # - name: Create commit - # if: steps.filter.outputs.addedOrModified == 'true' - # uses: stefanzweifel/git-auto-commit-action@v4 - # with: - # push_options: --force - # commit_message: Auto-generate chart README + - name: Create commit + if: steps.filter.outputs.addedOrModified == 'true' + uses: stefanzweifel/git-auto-commit-action@v4 + with: + push_options: --force + commit_message: Auto-generate chart changelog annotation - # commit_user_name: ${{ github.actor }} - # commit_user_email: ${{ github.actor }}@users.noreply.github.com + commit_user_name: ${{ github.actor }} + commit_user_email: ${{ github.actor }}@users.noreply.github.com - # file_pattern: charts/**/ + file_pattern: charts/**/Chart.yaml diff --git a/charts/incubator/seafile/Chart.yaml b/charts/incubator/seafile/Chart.yaml index 5a54fb11..d3bad85b 100644 --- a/charts/incubator/seafile/Chart.yaml +++ b/charts/incubator/seafile/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: 8.0.7 description: seafile helm package name: seafile -version: 1.2.1 +version: 2.0.0 kubeVersion: ">=1.16.0-0" keywords: - seafile @@ -16,8 +16,20 @@ maintainers: dependencies: - name: common repository: https://library-charts.k8s-at-home.com - version: 4.2.0 + version: 4.3.0 - name: mariadb - version: 9.7.1 + version: 10.2.0 repository: https://charts.bitnami.com/bitnami condition: mariadb.enabled +annotations: + artifacthub.io/changes: | + - kind: changed + description: "**Breaking:** Updated `mariadb` chart to version `10.2.0`. Check out the chart documentation to see which values have changed." + links: + - name: Chart documentation + url: https://github.com/bitnami/charts/tree/master/bitnami/mariadb#to-1000 + - kind: changed + description: Updated the common library dependency to version `4.3.0`. + links: + - name: Chart repository + url: https://github.com/k8s-at-home/library-charts/tree/common-4.3.0/charts/stable/common diff --git a/charts/incubator/seafile/README.md b/charts/incubator/seafile/README.md index 5d592586..a2d3c8c0 100644 --- a/charts/incubator/seafile/README.md +++ b/charts/incubator/seafile/README.md @@ -1,6 +1,6 @@ # seafile -![Version: 1.2.1](https://img.shields.io/badge/Version-1.2.1-informational?style=flat-square) ![AppVersion: 8.0.7](https://img.shields.io/badge/AppVersion-8.0.7-informational?style=flat-square) +![Version: 2.0.0](https://img.shields.io/badge/Version-2.0.0-informational?style=flat-square) ![AppVersion: 8.0.7](https://img.shields.io/badge/AppVersion-8.0.7-informational?style=flat-square) seafile helm package @@ -18,8 +18,8 @@ Kubernetes: `>=1.16.0-0` | Repository | Name | Version | |------------|------|---------| -| https://charts.bitnami.com/bitnami | mariadb | 9.7.1 | -| https://library-charts.k8s-at-home.com | common | 4.2.0 | +| https://charts.bitnami.com/bitnami | mariadb | 10.2.0 | +| https://library-charts.k8s-at-home.com | common | 4.3.0 | ## TL;DR @@ -93,25 +93,24 @@ N/A ## Changelog -All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common#changelog). - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -### [1.0.0] +### Version 2.0.0 #### Added -- Initial version +N/A #### Changed -- N/A +* **Breaking:** Updated `mariadb` chart to version `10.2.0`. Check out the chart documentation to see which values have changed. +* Updated the common library dependency to version `4.3.0`. -#### Removed +#### Fixed -- N/A +N/A -[1.0.0]: #100 +### Older versions + +A historical overview of changes can be found on [ArtifactHUB](https://artifacthub.io/packages/helm/k8s-at-home/seafile?modal=changelog) ## Support @@ -121,4 +120,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Join our [Discord](https://discord.gg/sTMX7Vh) community ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v0.1.1](https://github.com/k8s-at-home/helm-docs/releases/v0.1.1) diff --git a/charts/incubator/seafile/README.md.gotmpl b/charts/incubator/seafile/README.md.gotmpl index 358abe31..94f7808a 100644 --- a/charts/incubator/seafile/README.md.gotmpl +++ b/charts/incubator/seafile/README.md.gotmpl @@ -106,6 +106,36 @@ helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} - - Join our [Discord](https://discord.gg/sTMX7Vh) community {{- end -}} +{{- define "custom.changelog" -}} +{{ $changeTypes := list "added" "changed" "fixed" }} +## Changelog + +### Version {{ template "chart.version" . }} + +{{ range $changeType := $changeTypes }} + {{- with (index $.Annotations "artifacthub.io/changes") }} + {{- print "#### " ($changeType | title) | nindent 0 }} + {{- print "" | nindent 0 }} + {{- $changesFound := false }} + {{- range (print "changes:\n" . | fromYaml).changes }} + {{- if eq .kind $changeType }} + {{- print "* " .description | nindent 0 }} + {{- $changesFound = true }} + {{- end }} + {{- end }} + {{- if not $changesFound }} + {{- print "N/A" | nindent 0 }} + {{- end }} + {{- print "" | nindent 0 }} + {{- end }} +{{- end }} + +### Older versions + +A historical overview of changes can be found on [ArtifactHUB](https://artifacthub.io/packages/helm/k8s-at-home/{{- template "chart.name" . }}?modal=changelog) + +{{- end -}} + {{ template "chart.header" . }} {{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} diff --git a/charts/incubator/seafile/README_CHANGELOG.md.gotmpl b/charts/incubator/seafile/README_CHANGELOG.md.gotmpl deleted file mode 100644 index 06ad5fb3..00000000 --- a/charts/incubator/seafile/README_CHANGELOG.md.gotmpl +++ /dev/null @@ -1,27 +0,0 @@ -{{- define "custom.changelog.header" -}} -## Changelog -{{- end -}} - -{{- define "custom.changelog" -}} -{{ template "custom.changelog.header" . }} - -All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common#changelog). - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -### [1.0.0] - -#### Added - -- Initial version - -#### Changed - -- N/A - -#### Removed - -- N/A - -[1.0.0]: #100 -{{- end -}} diff --git a/hack/check-releasenotes.sh b/hack/check-releasenotes.sh new file mode 100755 index 00000000..de2c8784 --- /dev/null +++ b/hack/check-releasenotes.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -eu + +# Check if release notes have been changed +# Usage ./check-releasenotes.sh path + +# require yq +command -v yq >/dev/null 2>&1 || { + echo >&2 "yq (https://github.com/mikefarah/yq) is not installed. Aborting." + exit 1 +} + +# Absolute path of repository +repository=$(git rev-parse --show-toplevel) + +# Allow for a specific chart to be passed in as a argument +if [ $# -ge 1 ] && [ -n "$1" ]; then + root="$1" + chart_file="${1}/Chart.yaml" + if [ ! -f "$chart_file" ]; then + echo "File ${chart_file} does not exist." + exit 1 + fi + + echo "Validating release notes for $root" + + cd $root + CURRENT=$(cat Chart.yaml | yq e '.annotations."artifacthub.io/changes"' -P -) + + if [ "$CURRENT" == "" ] || [ "$CURRENT" == "null" ]; then + echo >&2 "Release notes have not been set for this chart!" + exit 1 + fi + + DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}') + ORIGINAL=$(git show origin/$DEFAULT_BRANCH:./Chart.yaml | yq e '.annotations."artifacthub.io/changes"' -P -) + + if [ "$CURRENT" == "$ORIGINAL" ]; then + echo >&2 "Release notes have not been updated!" + exit 1 + fi +else + echo >&2 "No chart folder has been specified." + exit 1 +fi diff --git a/hack/gen-helm-docs.sh b/hack/gen-helm-docs.sh index ec3f0e19..7fc0228a 100755 --- a/hack/gen-helm-docs.sh +++ b/hack/gen-helm-docs.sh @@ -16,7 +16,6 @@ repository=$(git rev-parse --show-toplevel) # Templates to copy into each chart directory readme_template="${repository}/hack/templates/README.md.gotmpl" readme_config_template="${repository}/hack/templates/README_CONFIG.md.gotmpl" -readme_changelog_template="${repository}/hack/templates/README_CHANGELOG.md.gotmpl" # Gather all charts using the common library, excluding common-test charts=$(find "${repository}" -name "Chart.yaml") @@ -40,8 +39,6 @@ for chart in ${charts}; do cp "${readme_template}" "${chart_directory}" # Copy CONFIG template to each Chart directory, do not overwrite if exists cp -n "${readme_config_template}" "${chart_directory}" || true - # Copy CHANGELOG template to each Chart directory, do not overwrite if exists - cp -n "${readme_changelog_template}" "${chart_directory}" || true done # Run helm-docs for charts using the common library and the common library itself @@ -49,5 +46,4 @@ helm-docs \ --ignore-file="${repository}/.helmdocsignore" \ --template-files="$(basename "${readme_template}")" \ --template-files="$(basename "${readme_config_template}")" \ - --template-files="$(basename "${readme_changelog_template}")" \ --chart-search-root="${root}" diff --git a/hack/renovate-releasenotes.sh b/hack/renovate-releasenotes.sh new file mode 100755 index 00000000..886d9a3d --- /dev/null +++ b/hack/renovate-releasenotes.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -eu + +# Check if release notes have been changed +# Usage ./check-releasenotes.sh path + +# require yq +command -v yq >/dev/null 2>&1 || { + echo >&2 "yq (https://github.com/mikefarah/yq) is not installed. Aborting." + exit 1 +} + +# Allow for a specific chart to be passed in as a argument +if [ $# -ge 1 ] && [ -n "$1" ]; then + root="$1" + chart_file="${1}/Chart.yaml" + if [ ! -f "$chart_file" ]; then + echo "File ${chart_file} does not exist." + exit 1 + fi + cd $root + DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}') + + echo "Generating release notes for $root" + + # Loop over all dependencies in current chart version + NEW_DEPENDENCIES=$(cat Chart.yaml | yq e '.dependencies[].name' -P - | LC_ALL=C sort) + OLD_DEPENDENCIES=$(git show origin/$DEFAULT_BRANCH:./Chart.yaml | yq e '.dependencies[].name' -P - | LC_ALL=C sort) + + tmpfile=$(mktemp) + trap 'rm -f "$tmpfile"' EXIT + + for DEP_NAME in ${NEW_DEPENDENCIES[@]} + do + NEW_VERSION=$(cat Chart.yaml | yq e ".dependencies[] | select(.name == \"$DEP_NAME\") | .version" -P -) + OLD_VERSION=$(git show origin/$DEFAULT_BRANCH:./Chart.yaml | yq e ".dependencies[] | select(.name == \"$DEP_NAME\") | .version" -P -) + if [ "${NEW_VERSION}" != "${OLD_VERSION}" ]; then + echo "- kind: changed" >> $tmpfile + echo " description: Upgraded \`${DEP_NAME}\` chart dependency to version \`${NEW_VERSION}\`." >> $tmpfile + fi + done + + yq eval-all --inplace 'select(fileIndex == 0).annotations."artifacthub.io/changes" = (select(fileIndex == 1) | to_yaml) | select(fileIndex==0)' Chart.yaml $tmpfile +else + echo >&2 "No chart folder has been specified." + exit 1 +fi diff --git a/hack/templates/README.md.gotmpl b/hack/templates/README.md.gotmpl index 358abe31..94f7808a 100644 --- a/hack/templates/README.md.gotmpl +++ b/hack/templates/README.md.gotmpl @@ -106,6 +106,36 @@ helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} - - Join our [Discord](https://discord.gg/sTMX7Vh) community {{- end -}} +{{- define "custom.changelog" -}} +{{ $changeTypes := list "added" "changed" "fixed" }} +## Changelog + +### Version {{ template "chart.version" . }} + +{{ range $changeType := $changeTypes }} + {{- with (index $.Annotations "artifacthub.io/changes") }} + {{- print "#### " ($changeType | title) | nindent 0 }} + {{- print "" | nindent 0 }} + {{- $changesFound := false }} + {{- range (print "changes:\n" . | fromYaml).changes }} + {{- if eq .kind $changeType }} + {{- print "* " .description | nindent 0 }} + {{- $changesFound = true }} + {{- end }} + {{- end }} + {{- if not $changesFound }} + {{- print "N/A" | nindent 0 }} + {{- end }} + {{- print "" | nindent 0 }} + {{- end }} +{{- end }} + +### Older versions + +A historical overview of changes can be found on [ArtifactHUB](https://artifacthub.io/packages/helm/k8s-at-home/{{- template "chart.name" . }}?modal=changelog) + +{{- end -}} + {{ template "chart.header" . }} {{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} diff --git a/hack/templates/README_CHANGELOG.md.gotmpl b/hack/templates/README_CHANGELOG.md.gotmpl deleted file mode 100644 index d456fa08..00000000 --- a/hack/templates/README_CHANGELOG.md.gotmpl +++ /dev/null @@ -1,27 +0,0 @@ -{{- define "custom.changelog.header" -}} -## Changelog -{{- end -}} - -{{- define "custom.changelog" -}} -{{ template "custom.changelog.header" . }} - -All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/commonREADME.md#Changelog). - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -### [1.0.0] - -#### Added - -- N/A - -#### Changed - -- N/A - -#### Removed - -- N/A - -[1.0.0]: #1.0.0 -{{- end -}} diff --git a/templates/chart/Chart.yaml b/templates/chart/Chart.yaml index 0e487cbf..a6f8f671 100644 --- a/templates/chart/Chart.yaml +++ b/templates/chart/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: 1.0.0 description: ${CHARTNAME} helm package name: ${CHARTNAME} -version: 2.1.0 +version: 1.0.0 kubeVersion: ">=1.16.0-0" keywords: - ${CHARTNAME} @@ -16,4 +16,8 @@ maintainers: dependencies: - name: common repository: https://library-charts.k8s-at-home.com - version: 4.2.0 + version: 4.3.0 +annotations: + artifacthub.io/changes: | + - kind: added + description: Initial version diff --git a/templates/chart/README.md b/templates/chart/README.md index 7f8bacc9..0a7a0162 100644 --- a/templates/chart/README.md +++ b/templates/chart/README.md @@ -86,11 +86,7 @@ N/A ## Changelog -All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common#changelog). - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -### [1.0.0] +### Version 1.0.0 #### Added @@ -98,13 +94,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), #### Changed -- N/A +N/A -#### Removed +#### Fixed -- N/A - -[1.0.0]: #1.0.0 +N/A ## Support diff --git a/templates/chart/README.md.gotmpl b/templates/chart/README.md.gotmpl index 358abe31..94f7808a 100644 --- a/templates/chart/README.md.gotmpl +++ b/templates/chart/README.md.gotmpl @@ -106,6 +106,36 @@ helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} - - Join our [Discord](https://discord.gg/sTMX7Vh) community {{- end -}} +{{- define "custom.changelog" -}} +{{ $changeTypes := list "added" "changed" "fixed" }} +## Changelog + +### Version {{ template "chart.version" . }} + +{{ range $changeType := $changeTypes }} + {{- with (index $.Annotations "artifacthub.io/changes") }} + {{- print "#### " ($changeType | title) | nindent 0 }} + {{- print "" | nindent 0 }} + {{- $changesFound := false }} + {{- range (print "changes:\n" . | fromYaml).changes }} + {{- if eq .kind $changeType }} + {{- print "* " .description | nindent 0 }} + {{- $changesFound = true }} + {{- end }} + {{- end }} + {{- if not $changesFound }} + {{- print "N/A" | nindent 0 }} + {{- end }} + {{- print "" | nindent 0 }} + {{- end }} +{{- end }} + +### Older versions + +A historical overview of changes can be found on [ArtifactHUB](https://artifacthub.io/packages/helm/k8s-at-home/{{- template "chart.name" . }}?modal=changelog) + +{{- end -}} + {{ template "chart.header" . }} {{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} diff --git a/templates/chart/README_CHANGELOG.md.gotmpl b/templates/chart/README_CHANGELOG.md.gotmpl deleted file mode 100644 index 06ad5fb3..00000000 --- a/templates/chart/README_CHANGELOG.md.gotmpl +++ /dev/null @@ -1,27 +0,0 @@ -{{- define "custom.changelog.header" -}} -## Changelog -{{- end -}} - -{{- define "custom.changelog" -}} -{{ template "custom.changelog.header" . }} - -All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common#changelog). - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -### [1.0.0] - -#### Added - -- Initial version - -#### Changed - -- N/A - -#### Removed - -- N/A - -[1.0.0]: #100 -{{- end -}}