Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate changelogs for use by chart releaser #149

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/CHANGELOG.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ $chart := (ds "chart") -}}
{{ $changes := (ds "changes") -}}
# {{ $chart.name }} Changelog

## {{ $chart.version }}

{{- range $kind := $changes }}

### {{ $kind.key | strings.Title }}

{{- range $change := $kind.value }}
- {{ $change.description }}
{{- end }}

{{- end }}
1 change: 1 addition & 0 deletions .github/ct/ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ skip-missing-values: true
release-label: release
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
release-notes-file: CHANGELOG.md
22 changes: 22 additions & 0 deletions .github/generate-chart-changelogs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -euo pipefail

CHART_DIR=charts

for dir in "$CHART_DIR"/*; do
if test ! -f "${dir}/Chart.yaml"; then
echo "Skipping over ${dir}"
continue
fi

CHART_NAME=$(basename "$dir")

echo "Creating CHANGELOG.md for ${CHART_NAME}"

cat "$dir/Chart.yaml" |
yq e '.annotations["artifacthub.io/changes"]' - | # extract the changes annotation, which is a YAML array
yq -o json e '.' - | # convert the YAML array to a JSON array
jq 'group_by(.kind) | to_entries | map({key: .value[0].kind, value: .value})' - | # group the JSON array by their 'kind' - ie. the type of change
gomplate -d chart="$dir/Chart.yaml" -d changes=stdin:///in.json -f .github/CHANGELOG.md.gotmpl >"$dir/CHANGELOG.md" # use the JSON above as input to render the changelog

done
18 changes: 11 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,29 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Check if documentation is up-to-date
run: bash generate-docs.sh && git diff --exit-code HEAD
run: generate-docs.sh && git diff --exit-code HEAD

- name: Update dependencies
run: find charts/ ! -path charts/ -maxdepth 1 -type d -exec helm dependency update {} \;

- name: Run YAML lint
run: yamllint .

- name: Run chart-testing (lint)
run: ct lint --config .github/ct/ct.yaml

- name: Run Powerlint
env:
# Don't support 1.22 yet since we can't explicitely pass a a Kubernetes version number to
# `helm template`
KUBERNETES_VERSIONS: "1.18.0 1.19.0 1.20.0 1.21.0"
run: bash chart-powerlint.sh
run: chart-powerlint.sh

# used to test whether the changelog generation process works properly
- name: Generate changelogs (test)
run: .github/generate-chart-changelogs.sh

test:
runs-on: ubuntu-20.04
Expand All @@ -47,11 +56,6 @@ jobs:
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.5.2

- uses: actions/setup-python@v2
with:
python-version: 3.9
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@ jobs:
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"

- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0

- name: Add bitnami repo
run: helm repo add bitnami https://charts.bitnami.com/bitnami

- name: Update dependencies
run: find charts/ ! -path charts/ -maxdepth 1 -type d -exec helm dependency update {} \;

- name: Generate changelogs
run: .github/generate-chart-changelogs.sh

- name: Run chart-releaser
uses: helm/[email protected]
with:
config: .github/ct/ct.yaml
version: 1.3.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
4 changes: 2 additions & 2 deletions charts/fhir-server-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ annotations:
# When using the list of objects option the valid supported kinds are
# added, changed, deprecated, removed, fixed and security.
- kind: changed
description: updated exporter to latest version
version: 0.3.1
description: version bump to test changelog generation
version: 0.3.2
8 changes: 7 additions & 1 deletion charts/fhir-server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ maintainers:
sources:
- https://github.com/microsoft/fhir-server
type: application
version: 0.5.12
annotations:
artifacthub.io/changes: |
# When using the list of objects option the valid supported kinds are added,
# changed, deprecated, removed, fixed and security.
- kind: changed
description: version bump to test changelog generation
version: 0.5.13
7 changes: 3 additions & 4 deletions charts/ohdsi/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ dependencies:
version: 10.12.7
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
appVersion: 2.10.0
annotations:
artifacthub.io/changes: |
# When using the list of objects option the valid supported kinds are added,
# changed, deprecated, removed, fixed and security.
- kind: changed
description: |
updated WebAPI and Atlas to v2.10.0
version: 0.7.3
appVersion: 2.10.0
description: version bump to test changelog generation
version: 0.7.4