feat: Add basic logic for changelog generation (#923)

This commit is contained in:
Kjeld Schouten-Lebbing
2021-09-08 00:23:29 +02:00
committed by GitHub
parent 8f7046e1e9
commit 6c4a7ddfcc
5 changed files with 91 additions and 6 deletions

22
.chglog/CHANGELOG.tpl.md Normal file
View File

@@ -0,0 +1,22 @@
{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
* {{ .Subject }}
{{ end }}
{{ end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

27
.chglog/config.yml Normal file
View File

@@ -0,0 +1,27 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/truecharts/apps
options:
commits:
# filters:
# Type:
# - feat
# - fix
# - perf
# - refactor
commit_groups:
# title_maps:
# feat: Features
# fix: Bug Fixes
# perf: Performance Improvements
# refactor: Code Refactoring
header:
pattern: "^(\\w*)\\:\\s(.*)$"
pattern_maps:
- Type
- Subject
notes:
keywords:
- BREAKING CHANGE

View File

@@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
concurrency: gitpush
container:
image: ghcr.io/truecharts/truecharts-release:v1.0.0
image: ghcr.io/truecharts/truecharts-release:v1.2.0
steps:
- name: Cache helm repo cache
id: cache

View File

@@ -196,7 +196,7 @@ jobs:
release-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/truecharts/truecharts-release:v1.0.0
image: ghcr.io/truecharts/truecharts-release:v1.2.0
steps:
- name: Cache helm repo cache
id: cache

View File

@@ -78,6 +78,7 @@ main() {
chartversion=$(cat ${chart}/Chart.yaml | grep "^version: " | awk -F" " '{ print $2 }')
chartname=$(basename ${chart})
train=$(basename $(dirname "$chart"))
create_changelog "$chart" "$chartname" "$train" "$chartversion"
generate_docs "$chart" "$chartname" "$train" "$chartversion"
copy_docs "$chart" "$chartname" "$train" "$chartversion"
helm dependency update "${chart}" --skip-refresh
@@ -98,6 +99,14 @@ main() {
release_charts
update_index
fi
for chart in "${changed_charts[@]}"; do
if [[ -d "$chart" ]]; then
chartversion=$(cat ${chart}/Chart.yaml | grep "^version: " | awk -F" " '{ print $2 }')
chartname=$(basename ${chart})
train=$(basename $(dirname "$chart"))
edit_release "$chart" "$chartname" "$train" "$chartversion"
fi
done
else
echo "Nothing to do. No chart changes detected."
fi
@@ -105,6 +114,30 @@ main() {
popd > /dev/null
}
edit_release() {
local chart="$1"
local chartname="$2"
local train="$3"
local chartversion="$4"
# In here we can in the future add code to edit the release notes of the github releases
# For example: using the github API: https://docs.github.com/en/rest/reference/repos#update-a-release
}
create_changelog() {
local chart="$1"
local chartname="$2"
local train="$3"
local chartversion="$4"
local prevversion="$(git tag -l "${chartname}-*" --sort=-v:refname | head -n 1)"
if [[ -z "$standalone" ]]; then
echo "Generating changelogs for: ${chartname}"
# SCALE "Changelog" containing only last change
git-chglog --next-tag ${chartversion} --tag-filter-pattern ${chartname} --path ${chart} ${chartversion} -o ${chart}/SCALE/CHANGELOG.md
# Append SCALE changelog to actual changelog
cat ${chart}/SCALE/CHANGELOG.md | cat - ${chart}/CHANGELOG.md > temp && mv temp ${chart}/CHANGELOG.md
fi
}
copy_general_docs() {
yes | cp -rf index.yaml docs/index.yaml 2>/dev/null || :
yes | cp -rf .github/README.md docs/index.md 2>/dev/null || :
@@ -176,6 +209,7 @@ copy_docs() {
else
mkdir -p docs/apps/${train}/${chartname} || echo "app path already exists, continuing..."
yes | cp -rf ${chart}/README.md docs/apps/${train}/${chartname}/index.md 2>/dev/null || :
yes | cp -rf ${chart}/CHANGELOG.md docs/apps/${train}/${chartname}/CHANGELOG.md 2>/dev/null || :
yes | cp -rf ${chart}/CONFIG.md docs/apps/${train}/${chartname}/CONFIG.md 2>/dev/null || :
yes | cp -rf ${chart}/helm-values.md docs/apps/${train}/${chartname}/helm-values.md 2>/dev/null || :
sed -i '1s/^/# License<br>\n\n/' docs/apps/${train}/${chartname}/LICENSE.md 2>/dev/null || :
@@ -207,12 +241,14 @@ patch_apps() {
local chartversion="$4"
local target="catalog/${train}/${chartname}/${chartversion}"
echo "Applying SCALE patches for App: ${chartname}"
mv ${target}/SCALE/ix_values.yaml ${target}/
mv ${target}/SCALE/questions.yaml ${target}/
rm -rf ${target}/CHANGELOG.md 2>/dev/null || :
mv ${target}/SCALE/CHANGELOG.md ${target}/CHANGELOG.md 2>/dev/null || :
mv ${target}/SCALE/ix_values.yaml ${target}/ 2>/dev/null || :
mv ${target}/SCALE/questions.yaml ${target}/ 2>/dev/null || :
cp -rf ${target}/SCALE/templates/* ${target}/templates 2>/dev/null || :
mv ${target}/SCALE/item.yaml catalog/${train}/${chartname}/item.yaml
rm -rf ${target}/SCALE
mv ${target}/values.yaml ${target}/test_values.yaml
rm -rf ${target}/SCALE 2>/dev/null || :
mv ${target}/values.yaml ${target}/test_values.yaml 2>/dev/null || :
touch ${target}/values.yaml
}