From ff654486b3d869b0f4e03e087b470ba3c197080c Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Thu, 10 Nov 2022 20:39:03 +0100 Subject: [PATCH] feat(ci): move changelog directly to website (#4370) * feat(ci): move changelog directly to website * Put part of website changelog into SCALE App and add notice towards website * Don't push back into repo and combine helm-release jobs * force remove app-changelog --- .github/scripts/build-catalog.sh | 8 +- .github/scripts/changelog.sh | 21 ++++ .github/scripts/gen-docs.sh | 40 -------- .github/workflows/charts-release.yaml | 132 ++++---------------------- 4 files changed, 43 insertions(+), 158 deletions(-) create mode 100755 .github/scripts/changelog.sh delete mode 100755 .github/scripts/gen-docs.sh diff --git a/.github/scripts/build-catalog.sh b/.github/scripts/build-catalog.sh index ee216432e1f..eca4d4e94e2 100755 --- a/.github/scripts/build-catalog.sh +++ b/.github/scripts/build-catalog.sh @@ -55,8 +55,6 @@ patch_apps() { local chartversion="$4" local target="catalog/${train}/${chartname}/${chartversion}" echo "Applying SCALE patches for Chart: ${chartname}" - sed -i '100,$ d' ${target}/CHANGELOG.md || : - mv ${target}/app-changelog.md ${target}/CHANGELOG.md 2>/dev/null || : # Temporary fix to prevent the UI from bugging out on 21.08 mv ${target}/values.yaml ${target}/ix_values.yaml 2>/dev/null || : touch ${target}/values.yaml @@ -77,6 +75,12 @@ patch_apps() { sed -i "s|^icon:|icon_url:|g" catalog/${train}/${chartname}/item.yaml echo "categories:" >> catalog/${train}/${chartname}/item.yaml cat ${target}/Chart.yaml | yq '.annotations."truecharts.org/catagories"' -r >> catalog/${train}/${chartname}/item.yaml + # Copy changelog from website + cp -rf "website/docs/charts/${train}/${chart}/CHANGELOG.md" "${target}/CHANGELOG.md" 2>/dev/null || : + sed -i '1d' "${target}/CHANGELOG.md" + sed -i '1s/^/*for the complete changelog, please refer to the website*\n\n/' "website/docs/charts/${train}/${chart}/CHANGELOG.md" + sed -i '1s/^/**Important:**\n/' "website/docs/charts/${train}/${chart}/CHANGELOG.md" + sed -i '100,$ d' "${target}/CHANGELOG.md" || : # Generate SCALE App description file cat ${target}/Chart.yaml | yq .description -r >> ${target}/app-readme.md echo "" >> ${target}/app-readme.md diff --git a/.github/scripts/changelog.sh b/.github/scripts/changelog.sh new file mode 100755 index 00000000000..036496b6a1a --- /dev/null +++ b/.github/scripts/changelog.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -o errexit +set -o nounset +set -o pipefail + +if [[ -d "charts/${1}" ]]; then + echo "Start processing charts/${1} ..." + chart="charts/${1}" + chartversion=$(cat charts/${1}/Chart.yaml | grep "^version: " | awk -F" " '{ print $2 }') + chartname=$(basename charts/${1}) + train=$(basename $(dirname "charts/${1}")) + SCALESUPPORT=$(cat charts/${1}/Chart.yaml | yq '.annotations."truecharts.org/SCALE-support"' -r) + # Ensure to start with a clean slate + rm -rf ${chart}/app-changelog.md || echo "changelog not found..." + echo "Generating changelogs for: ${chartname}" + # SCALE "Changelog" containing only last change + git-chglog --next-tag ${chartname}-${chartversion} --tag-filter-pattern ${chartname} --path ${chart} -o ${chart}/app-changelog.md ${chartname}-${chartversion} || echo "changelog generation failed..." +else + echo "Chart 'charts/${1}' no longer exists in repo. Skipping it..." +fi +echo "Done processing charts/${1} ..." diff --git a/.github/scripts/gen-docs.sh b/.github/scripts/gen-docs.sh deleted file mode 100755 index fb5065b0ee7..00000000000 --- a/.github/scripts/gen-docs.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash -set -o errexit -set -o nounset -set -o pipefail - -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)" - echo "Generating changelogs for: ${chartname}" - # SCALE "Changelog" containing only last change - git-chglog --next-tag ${chartname}-${chartversion} --tag-filter-pattern ${chartname} --path ${chart} -o ${chart}/app-changelog.md ${chartname}-${chartversion} - # Append SCALE changelog to actual changelog - - if [[ -f "${chart}/CHANGELOG.md" ]]; then - true - else - touch ${chart}/CHANGELOG.md - fi - sed -i '1d' ${chart}/CHANGELOG.md - cat ${chart}/app-changelog.md | cat - ${chart}/CHANGELOG.md > temp && mv temp ${chart}/CHANGELOG.md - sed -i '1s/^/# Changelog\n\n/' ${chart}/CHANGELOG.md - rm ${chart}/app-changelog.md || echo "changelog not found..." - } - export -f create_changelog - - -if [[ -d "charts/${1}" ]]; then - echo "Start processing charts/${1} ..." - chartversion=$(cat charts/${1}/Chart.yaml | grep "^version: " | awk -F" " '{ print $2 }') - chartname=$(basename charts/${1}) - train=$(basename $(dirname "charts/${1}")) - SCALESUPPORT=$(cat charts/${1}/Chart.yaml | yq '.annotations."truecharts.org/SCALE-support"' -r) - create_changelog "charts/${1}" "${chartname}" "$train" "${chartversion}" || echo "changelog generation failed..." -else - echo "Chart 'charts/${1}' no longer exists in repo. Skipping it..." -fi -echo "Done processing charts/${1} ..." diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 5f46b22df42..c7da965887f 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -44,14 +44,14 @@ jobs: id: collect-changes uses: ./.github/actions/collect-changes - - name: Generate README for changed charts + - name: Generate Changelog shell: bash if: | steps.collect-changes.outputs.changesDetectedAfterTag == 'true' run: | CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }}) parthreads=$(($(nproc) * 2)) - parallel -j ${parthreads} .github/scripts/gen-docs.sh '2>&1' ::: ${CHARTS[@]} + parallel -j ${parthreads} .github/scripts/changelog.sh '2>&1' ::: ${CHARTS[@]} - name: Fix Pre-Commit issues shell: bash @@ -91,35 +91,21 @@ jobs: echo "copying docs to website for ${chart}" rm -rf website/docs/charts/*/${chart} mkdir -p website/docs/charts/${train}/${chart} || echo "chart path already exists, continuing..." - yes | cp -rf charts/${train}/${chart}/CHANGELOG.md website/docs/charts/${train}/${chart}/CHANGELOG.md 2>/dev/null || : yes | cp -rf charts/${train}/${chart}/docs/* website/docs/charts/${train}/${chart}/ 2>/dev/null || : yes | cp -rf charts/${train}/${chart}/icon.png website/static/img/hotlink-ok/chart-icons/${chart}.png 2>/dev/null || : + # Append SCALE changelog to actual changelog + if [[ -f "website/docs/charts/${train}/${chart}/CHANGELOG.md" ]]; then + true + else + touch "website/docs/charts/${train}/${chart}/CHANGELOG.md" + fi + sed -i '1d' "website/docs/charts/${train}/${chart}/CHANGELOG.md" + cat ${chart}/app-changelog.md | cat - "website/docs/charts/${train}/${chart}/CHANGELOG.md" > temp && mv temp "website/docs/charts/${train}/${chart}/CHANGELOG.md" + sed -i '1s/^/# Changelog\n\n/' "website/docs/charts/${train}/${chart}/CHANGELOG.md" + rm -rf ${chart}/app-changelog.md || echo "app-changelog not found..." fi done - - name: Create commit - id: create-commit - if: | - steps.collect-changes.outputs.changesDetectedAfterTag == 'true' - uses: stefanzweifel/git-auto-commit-action@49620cd3ed21ee620a48530e81dba0d139c9cb80 # v4 - with: - file_pattern: charts/**/ - commit_message: "chore: Auto-update chart README [skip ci]" - commit_user_name: truecharts-bot - commit_user_email: bot@truecharts.org - commit_author: truecharts-bot - - - name: Save commit hash - id: save-commit-hash - if: | - steps.collect-changes.outputs.changesDetectedAfterTag == 'true' - run: | - if [ "${{ steps.create-commit.outputs.changes_detected || 'unknown' }}" = "true" ]; then - echo '::set-output name=commit_hash::${{ steps.create-commit.outputs.commit_hash }}' - else - echo "::set-output name=commit_hash::${GITHUB_SHA}" - fi - - name: Commit Website Changes if: | steps.collect-changes.outputs.changesDetected == 'true' @@ -133,7 +119,7 @@ jobs: cd - rm -rf website - - name: Checkout + - name: Checkout Catalog uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 if: | steps.collect-changes.outputs.changesDetectedAfterTag == 'true' @@ -144,7 +130,7 @@ jobs: ref: staging path: catalog - - name: build catalogs + - name: build catalog shell: bash if: | steps.collect-changes.outputs.changesDetectedAfterTag == 'true' @@ -167,7 +153,7 @@ jobs: cd - rm -rf catalog - release-helm-important: + release-helm: runs-on: ubuntu-latest container: image: ghcr.io/truecharts/devcontainer:v2.6.0@sha256:5029ebed5c833646da3afb3a8512eba79f08cac8935a53fc1510854fec22341a @@ -193,7 +179,6 @@ jobs: with: token: ${{ secrets.BOT_TOKEN }} fetch-depth: 0 - ref: ${{needs.release-scale.outputs.ref}} - name: Fix Pre-Commit issues shell: bash @@ -206,6 +191,7 @@ jobs: run: | git config user.name "truecharts-bot" git config user.email "bot@truecharts.org" + - name: Run chart-releaser for dependency apps uses: helm/chart-releaser-action@98bccfd32b0f76149d188912ac8e45ddd3f8695f # tag=v1.4.1 if: | @@ -216,7 +202,6 @@ jobs: env: CR_TOKEN: "${{ secrets.BOT_TOKEN }}" CR_SKIP_EXISTING: "true" - - name: Run chart-releaser for enterprise apps uses: helm/chart-releaser-action@98bccfd32b0f76149d188912ac8e45ddd3f8695f # tag=v1.4.1 if: | @@ -227,46 +212,6 @@ jobs: env: CR_TOKEN: "${{ secrets.BOT_TOKEN }}" CR_SKIP_EXISTING: "true" - - release-helm-stable: - runs-on: ubuntu-latest - container: - image: ghcr.io/truecharts/devcontainer:v2.6.0@sha256:5029ebed5c833646da3afb3a8512eba79f08cac8935a53fc1510854fec22341a - needs: ["release-scale", "release-helm-important"] - steps: - - name: Install Kubernetes tools - uses: yokawasa/action-setup-kube-tools@b91bb02bc122bd84ac7bbea5f25ed6b0f2ec6275 # tag=v0.9.2 - with: - setup-tools: | - helmv3 - helm: "3.8.0" - - - name: Prep Helm - run: | - helm repo add truecharts https://charts.truecharts.org - helm repo add truecharts-library https://library-charts.truecharts.org - helm repo add bitnami https://charts.bitnami.com/bitnami - - helm repo add prometheus https://prometheus-community.github.io/helm-charts - helm repo update - - name: Checkout - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 - with: - token: ${{ secrets.BOT_TOKEN }} - fetch-depth: 0 - ref: ${{needs.release-scale.outputs.ref}} - - - name: Fix Pre-Commit issues - shell: bash - 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 - - name: Configure Git - run: | - git config user.name "truecharts-bot" - git config user.email "bot@truecharts.org" - name: Run chart-releaser for stable uses: helm/chart-releaser-action@98bccfd32b0f76149d188912ac8e45ddd3f8695f # tag=v1.4.1 with: @@ -275,51 +220,6 @@ jobs: env: CR_TOKEN: "${{ secrets.BOT_TOKEN }}" CR_SKIP_EXISTING: "true" - - release-helm-incubator: - runs-on: ubuntu-latest - container: - image: ghcr.io/truecharts/devcontainer:v2.6.0@sha256:5029ebed5c833646da3afb3a8512eba79f08cac8935a53fc1510854fec22341a - needs: ["release-scale", "release-helm-stable", "release-helm-important"] - steps: - - name: Install Kubernetes tools - uses: yokawasa/action-setup-kube-tools@b91bb02bc122bd84ac7bbea5f25ed6b0f2ec6275 # tag=v0.9.2 - with: - setup-tools: | - helmv3 - helm: "3.8.0" - - - name: Install helm-docs - 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: Prep Helm - run: | - helm repo add truecharts https://charts.truecharts.org - helm repo add truecharts-library https://library-charts.truecharts.org - helm repo add bitnami https://charts.bitnami.com/bitnami - - - helm repo add prometheus https://prometheus-community.github.io/helm-charts - helm repo update - - name: Checkout - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3 - with: - token: ${{ secrets.BOT_TOKEN }} - fetch-depth: 0 - ref: ${{needs.release-scale.outputs.ref}} - - - name: Fix Pre-Commit issues - shell: bash - 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 - - name: Configure Git - run: | - git config user.name "truecharts-bot" - git config user.email "bot@truecharts.org" - name: Run chart-releaser for stable uses: helm/chart-releaser-action@98bccfd32b0f76149d188912ac8e45ddd3f8695f # tag=v1.4.1 with: