diff --git a/.github/scripts/chart-docs.sh b/.github/scripts/chart-docs.sh index 05f956c5d75..b7872e55dfb 100755 --- a/.github/scripts/chart-docs.sh +++ b/.github/scripts/chart-docs.sh @@ -2,35 +2,11 @@ [ "$DEBUG" == 'true' ] && set -x [ "$STRICT" == 'true' ] && set -e -make_sure_structure_is_there() { - local train="$1" - local chart="$2" - - mkdir -p tmp/website/src/content/docs/charts/${train}/${chart} || echo "chart path already exists, continuing..." - - echo "Checking if website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md exists" - if [ -f "website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md" ]; then - echo "CHANGELOG.md already exists, continuing..." - return 0 - fi - - mkdir -p "website/src/content/docs/charts/${train}/${chart}" || echo "chart path already exists, continuing..." - touch "website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md" -} - -keep_safe_docs() { - local train="$1" - local chart="$2" - - echo "Keeping some docs safe..." - mv -f website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md tmp/website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md || : -} - remove_old_docs() { local train="$1" local chart="$2" - echo "Removing old docs and recreating based on charts repo..." + echo "Removing old docs and recreating based on website repo..." rm -rf website/src/content/docs/charts/*/${chart} || : mkdir -p website/src/content/docs/charts/${train}/${chart} || echo "chart path already exists, continuing..." } @@ -46,30 +22,6 @@ copy_new_docs() { cp -rf charts/${train}/${chart}/screenshots/* website/public/img/hotlink-ok/chart-screenshots/${chart}/ 2>/dev/null || : } -copy_safe_docs() { - local train="$1" - local chart="$2" - - echo "copying safe docs to website for ${chart}" - cp -rf tmp/website/src/content/docs/charts/${train}/${chart}/* website/src/content/docs/charts/${train}/${chart}/ 2>/dev/null || : -} - -append_scale_changelog() { - local train="$1" - local chart="$2" - - echo "appending SCALE changelog to actual changelog..." - # Remove header from changelog - sed -i '/^---$/,/^---$/d' "website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md" - # Prepend app-changelog to changelog - cat "charts/${train}/${chart}/app-changelog.md" | - cat - "website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md" >temp && - mv temp "website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md" - - echo "Adding changelog header..." - # ./.github/scripts/frontmatter.sh "website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md" -} - check_and_fix_title() { local file="$1" @@ -187,13 +139,8 @@ main() { echo "copying docs to website for ${chart}" - make_sure_structure_is_there "$train" "$chart" - keep_safe_docs "$train" "$chart" remove_old_docs "$train" "$chart" copy_new_docs "$train" "$chart" - copy_safe_docs "$train" "$chart" - append_scale_changelog "$train" "$chart" - # ./.github/scripts/frontmatter.sh "website/src/content/docs/charts/${train}/${chart}/CHANGELOG.md" process_index "$train" "$chart" echo "Finished processing ${chart}" diff --git a/.github/scripts/frontmatter.sh b/.github/scripts/frontmatter.sh deleted file mode 100755 index 000adf906ba..00000000000 --- a/.github/scripts/frontmatter.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -[ "$DEBUG" == 'true' ] && set -x -[ "$STRICT" == 'true' ] && set -e - -file_path="$1" -base_cmd="go-yq --front-matter=process" - -echo "Checking front matter" -if ! head -n 1 "$file_path" | grep -q "^---$"; then - echo "Front matter (start) not found, adding it" - # Dont trace content, as its usually too large - [ "$DEBUG" == "true" ] && set +x - (echo -e "---\n---\n"; cat "$file_path") >"$file_path.tmp" && mv "$file_path.tmp" "$file_path" - [ "$DEBUG" == "true" ] && set -x -fi - -wc -l $file_path - -# Get the title from the front matter -echo "Updating title" -$base_cmd -i '.title="Changelog"' "$file_path" - -echo "Updating pagefind" -$base_cmd -i '.pagefind=false' "$file_path" diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 35ef9ee4eeb..491a0ebc174 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -36,11 +36,6 @@ jobs: # Fix sh files to always be executable find . -name '*.sh' | xargs chmod +x - - name: Clean Questions - shell: bash - run: | - find ./helm -type f -name 'questions.yaml' -exec rm {} \; - - name: Commit Helm Changes run: | rm -rf helm/charts @@ -57,20 +52,29 @@ jobs: git push cd - - - name: Fix Pre-Commit issues + - name: Cache Changelog + id: cache-changelog + uses: actions/cache@v4 + with: + path: changelog.json.gz + key: changelog-json + + - name: Generate Changelog shell: bash - if: | - steps.collect-changes.outputs.changesDetectedAfterTag == 'true' run: | - echo "Running pre-commit test-and-cleanup..." - pre-commit run --all ||: - # Fix sh files to always be executable - find . -name '*.sh' | xargs chmod +x + export REPO_PATH="./" + export TEMPLATE_PATH="templates/CHANGELOG.md.tmpl" + export CHARTS_DIR="./charts" + export JSON_FILE="changelog.json" + if [ -f "$JSON_FILE.gz" ]; then + gunzip "$JSON_FILE.gz" --force # Force overwrite if file already exists + fi + + ./charttool "$REPO_PATH" "$TEMPLATE_PATH" "$CHARTS_DIR" + gzip "$JSON_FILE" --best - name: Checkout uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 - if: | - steps.collect-changes.outputs.changesDetectedAfterTag == 'true' with: fetch-depth: 1 repository: truecharts/website @@ -78,8 +82,6 @@ jobs: path: website - name: Copy docs to website - if: | - steps.collect-changes.outputs.changesDetectedAfterTag == 'true' shell: bash run: | #!/bin/bash @@ -98,12 +100,12 @@ jobs: for i in "${CHARTS[@]}" do + # TODO: Remove any changelog stuff from this script + # TODO: Move all website docs structure generation to charttool ./.github/scripts/chart-docs.sh "$i" done - name: Commit Website Changes - if: | - steps.collect-changes.outputs.changesDetected == 'true' run: | cd website git config user.name "TrueCharts-Bot" diff --git a/templates/CHANGELOG.md.tmpl b/templates/CHANGELOG.md.tmpl new file mode 100644 index 00000000000..03115449827 --- /dev/null +++ b/templates/CHANGELOG.md.tmpl @@ -0,0 +1,18 @@ +--- +title: Changelog +pagefind: false +--- + +All history information can be found at [Github History](https://github.com/truecharts/charts/commits/master/charts/{{ .Train }}/{{ .Name }}) + +:::tip + +If you need more than 2 scrolls to find your current version, please consider updating the chart as soon as possible. + +::: +{{ range $key := .SortedVersions }} +## {{ $key }} • [Train: {{ (index $.Versions $key).Train }}] +{{ range $commit := (index $.Versions $key).SortedCommits }} +- {{ printf "%s • [`%s`](https://github.com/truecharts/charts/commit/%s) • [@%s] (%s)" $commit.Message (slice $commit.CommitHash 0 7) $commit.CommitHash $commit.Author.Name $commit.Author.Date -}} +{{ end }} +{{ end -}}