TrueChartsClone/.github/scripts/build-catalog.sh

157 lines
6.7 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
include_questions() {
local chart="$1"
local chartname="$2"
local train="$3"
local chartversion="$4"
local source="charts/${train}/${chartname}/questions.yaml"
local target="catalog/${train}/${chartname}/${chartversion}/questions.yaml"
echo "Making copy of $source to $target"
cp ${source} ${target}
echo "Including standardised questions.yaml includes for: ${chartname}"
sed -i -E 's:^.*# Include\{(.*)\}.*$:cat templates/questions/**/\1.yaml:e' ${target}
}
export -f include_questions
clean_catalog() {
local chart="$1"
local chartname="$2"
local train="$3"
local chartversion="$4"
cd catalog/${train}/${chartname}
local majorversions=$( (find . -mindepth 1 -maxdepth 1 -type d \( ! -iname ".*" \) | sed 's|^\./||g') | sort -Vr | cut -c1 | uniq)
echo "Removing old versions for: ${chartname}"
for majorversion in ${majorversions}; do
local maxofmajor=$( (find . -mindepth 1 -maxdepth 1 -type d \( -iname "${majorversion}.*" \) | sed 's|^\./||g') | sort -Vr | head -n1 )
local rmversions=$( (find . -mindepth 1 -maxdepth 1 -type d \( -iname "${majorversion}.*" \) \( ! -iname "${maxofmajor}" \) | sed 's|^\./||g') | sort -Vr )
rm -Rf ${rmversions}
done
cd -
}
export -f clean_catalog
clean_apps() {
local chart="$1"
local chartname="$2"
local train="$3"
local chartversion="$4"
echo "Cleaning SCALE catalog for Chart: ${chartname}"
rm -Rf catalog/${train}/${chartname}/${chartversion} 2>/dev/null || :
rm -Rf catalog/${train}/${chartname}/item.yaml 2>/dev/null || :
}
export -f clean_apps
patch_apps() {
local chart="$1"
local chartname="$2"
local train="$3"
local chartversion="$4"
local target="catalog/${train}/${chartname}/${chartversion}"
echo "Applying SCALE patches for Chart: ${chartname}"
# 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
# mv ${target}/SCALE/ix_values.yaml ${target}/ 2>/dev/null || :
cp -rf ${target}/SCALE/templates/* ${target}/templates 2>/dev/null || :
cp -rf ${target}/SCALE/migrations/* ${target}/migrations 2>/dev/null || :
rm -rf ${target}/SCALE 2>/dev/null || :
touch ${target}/values.yaml
# Remove content that is not required for the App to install
2022-07-06 20:38:12 +00:00
rm -rf ${target}/security.md
rm -rf ${target}/helm-values.md
rm -rf ${target}/CONFIG.md
rm -rf ${target}/docs
rm -rf ${target}/icon.png
rm -rf ${target}/ci
# Generate item.yaml
cat ${target}/Chart.yaml | grep "icon" >> catalog/${train}/${chartname}/item.yaml
sed -i "s|^icon:|icon_url:|g" catalog/${train}/${chartname}/item.yaml
echo "categories:" >> catalog/${train}/${chartname}/item.yaml
chore(ci): fix scripts (#14061) **Description** <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ⚒️ Fixes # <!--(issue)--> **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._
2023-10-28 17:12:33 +00:00
category=$(cat ${target}/Chart.yaml | yq '.annotations."truecharts.org/category"' -r)
echo "- $category" >> catalog/${train}/${chartname}/item.yaml
chore(ci): add screenshots generation (#9582) **Description** <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ⚒️ Fixes # <!--(issue)--> **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._
2023-06-13 07:56:52 +00:00
# Generate screenshots
Update build-catalog.sh (#9690) **Description** <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ⚒️ Fixes # <!--(issue)--> **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
2023-06-16 09:24:44 +00:00
screenshots=""
Fix chart release CI issue (#9684) **Description** <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ⚒️ Fixes # <!--(issue)--> Fixes issue causing chart release CI to fail due to non existent directory. **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [x] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [x] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._
2023-06-16 06:03:45 +00:00
if [[ -d "${target}/screenshots" ]]; then
screenshots=$(ls ${target}/screenshots)
fi
chore(ci): add screenshots generation (#9582) **Description** <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> ⚒️ Fixes # <!--(issue)--> **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._
2023-06-13 07:56:52 +00:00
if [[ -n $screenshots ]]; then
echo "screenshots:" >> catalog/${train}/${chartname}/item.yaml
for screenshot in $screenshots; do
echo " - https://truecharts.org/img/hotlink-ok/chart-screenshots/${chartname}/${screenshot}" >> catalog/${train}/${chartname}/item.yaml
done
else
echo "screenshots: []" >> catalog/${train}/${chartname}/item.yaml
fi
rm -rf ${target}/screenshots
# Copy changelog from website
2022-12-01 10:56:21 +00:00
if [[ ! -f "website/docs/charts/${train}/${chartname}/CHANGELOG.md" ]]; then
touch "website/docs/charts/${train}/${chartname}/CHANGELOG.md"
fi
2022-12-01 10:56:21 +00:00
cp -rf "website/docs/charts/${train}/${chartname}/CHANGELOG.md" "${target}/CHANGELOG.md" 2>/dev/null || :
2023-12-31 17:29:04 +00:00
if [[ grep -q "for the complete changelog, please refer to the website" "${target}/CHANGELOG.md" ]]; then
2023-12-31 15:57:50 +00:00
echo "Adding changelog notice for: ${chartname}"
# Count the frontmatter lines
line_count=$(sed -n '/^---$/,/^---$/p' "${target}/CHANGELOG.md" | wc -l)
# Increase the line count by 1
line_count=$((line_count + 1))
# Add a line to the changelog
sed -i "${line_count + 1}s/^/*for the complete changelog, please refer to the website*\n\n/" "${target}/CHANGELOG.md"
sed -i "${line_count + 1}s/^/**Important:**\n/" "${target}/CHANGELOG.md"
fi
2023-12-31 17:19:48 +00:00
echo "Truncating changelog for: ${chartname}"
2023-12-31 15:57:50 +00:00
# Truncate changelog to only contain the last 100 lines
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
echo "This App is supplied by TrueCharts, for more information visit the manual: [https://truecharts.org/charts/${train}/${chartname}](https://truecharts.org/charts/${train}/${chartname})" >> ${target}/app-readme.md
echo "" >> ${target}/app-readme.md
echo "---" >> ${target}/app-readme.md
echo "" >> ${target}/app-readme.md
echo "TrueCharts can only exist due to the incredible effort of our staff." >> ${target}/app-readme.md
echo "Please consider making a [donation](https://truecharts.org/sponsor) or contributing back to the project any way you can!" >> ${target}/app-readme.md
2023-12-31 17:19:48 +00:00
echo "app-readme generated"
}
export -f patch_apps
copy_apps() {
local chart="$1"
local chartname="$2"
local train="$3"
local chartversion="$4"
echo "Copying App to Catalog: ${2}"
mkdir -p catalog/${train}/${chartname}/${chartversion}
cp -Rf ${chart}/* catalog/${train}/${chartname}/${chartversion}/
}
export -f copy_apps
chore: move new-common incubator stuff to stable (#15646) **Description** Applications that are currently on new common in incubator are either working or unstable. We should act on that and filter accordingly **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [x] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration --> **📃 Notes:** <!-- Please enter any other relevant information here --> **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._
2023-12-03 21:49:05 +00:00
rm -rf charts/unstable
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)
if [[ "${SCALESUPPORT}" == "true" ]]; then
clean_apps "charts/${1}" "${chartname}" "$train" "${chartversion}"
copy_apps "charts/${1}" "${chartname}" "$train" "${chartversion}"
patch_apps "charts/${1}" "${chartname}" "$train" "${chartversion}"
include_questions "charts/${1}" "${chartname}" "$train" "${chartversion}"
clean_catalog "charts/${1}" "${chartname}" "$train" "${chartversion}"
else
echo "Skipping chart charts/${1}, no correct SCALE compatibility layer detected"
fi
else
echo "Chart 'charts/${1}' no longer exists in repo. Skipping it..."
fi
echo "Done processing charts/${1} ..."