rougail-tutorials_builder/build.sh

224 lines
8.1 KiB
Bash
Raw Normal View History

2024-07-21 11:27:47 +02:00
#!/bin/bash -e
2025-05-05 18:21:57 +02:00
#-----------------------
VERSION=1.1
#-----------------------
2024-07-21 11:27:47 +02:00
set -x
DEST=../rougail-tutorials
if [ -d $DEST ]; then
echo "déjà fait"
exit 1
fi
2025-11-09 14:20:04 +01:00
export LC_ALL=C.UTF-8
2024-07-21 11:27:47 +02:00
BUILDER="$(pwd)"
mkdir -p $DEST/firefox
2025-11-10 08:20:56 +01:00
rm -f summary.md previous.yml
2024-07-21 11:27:47 +02:00
touch summary.md
2025-05-05 18:21:57 +02:00
rm -f summary_total.md
touch summary_total.md
2024-07-21 11:27:47 +02:00
cd "$DEST"
DEST="$(pwd)"
2025-11-09 14:20:04 +01:00
TUTO_ROOT=https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit
2024-07-21 11:27:47 +02:00
cp "$BUILDER"/firefox.png .
cp "$BUILDER"/foxyproxy.png .
cp "$BUILDER"/summary.md .
2025-11-09 14:20:04 +01:00
cp "$BUILDER"/install.txt .
2026-06-14 09:33:16 +02:00
EMPTY=$(echo -e "\n")
2024-07-21 11:27:47 +02:00
touch README.md
2026-06-14 09:33:16 +02:00
"$BUILDER"/build.py "$BUILDER" "$VERSION" "false"
2024-07-21 11:27:47 +02:00
rm -rf summary.md
2025-05-05 18:21:57 +02:00
rm -rf summary_total.md
2024-07-21 11:27:47 +02:00
rm -rf jinja_caches
2026-06-14 09:33:16 +02:00
git init -b "$VERSION" > /dev/null
2024-07-21 11:27:47 +02:00
git add .
2026-06-14 09:33:16 +02:00
git commit -am"$(cat $BUILDER/TITLE)" > /dev/null
2025-05-05 18:21:57 +02:00
#old_commit_id="$(git rev-parse HEAD)"
2024-07-21 11:27:47 +02:00
cd - > /dev/null
for i in $(ls -d "examples"/* | sort); do
2025-11-09 14:20:04 +01:00
num=$(echo $(basename "$i"))
2026-06-14 09:33:16 +02:00
# echo "$num"
2025-11-09 14:20:04 +01:00
commit_id="v${VERSION}_$num"
2025-11-10 08:20:56 +01:00
title="$(head -n 1 $i/README.md)"
summary="[tutorial $commit_id] $title"
2025-11-09 14:20:04 +01:00
echo "- [$summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/$commit_id/README.md) ([diff](https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/${commit_id}~1..$commit_id))" >> summary_total.md
2025-05-05 18:21:57 +02:00
done
for i in $(ls -d "examples"/* | sort); do
2026-02-28 10:45:28 +01:00
if [ -f $i/URL ]; then
base_url_doc=$(cat $i/URL)
fi
2025-05-05 18:21:57 +02:00
if [ -f "$i/TITLE.md" ]; then
2026-06-14 09:33:16 +02:00
echo "- $(head -n 1 $i/TITLE.md)" >> summary.md
2025-05-05 18:21:57 +02:00
fi
if [ -f "$i/SUBTITLE.md" ]; then
2026-06-14 09:33:16 +02:00
echo " - $(head -n 1 $i/SUBTITLE.md) ([doc]($base_url_doc))" >> summary.md
2025-05-05 18:21:57 +02:00
fi
2024-07-21 11:27:47 +02:00
if [ -f "$i/README.md" ]; then
2025-11-09 14:20:04 +01:00
rm -rf "$DEST/config" "$DEST/tree.html"
2025-05-05 18:21:57 +02:00
num=$(echo $(basename "$i"))
2026-06-14 09:33:16 +02:00
echo "=== $num ==="
2025-11-03 18:01:10 +01:00
commit_id="v${VERSION}_$num"
2025-11-10 08:20:56 +01:00
title=$(head -n 1 $i/README.md)
2026-01-07 08:36:06 +01:00
summary="[tutorial $commit_id] $title"
2026-06-14 09:33:16 +02:00
url_doc="$base_url_doc#$(echo $title | tr A-Z a-z | sed 's/ /-/g' | sed 's//-/g' | sed 's/\"//g' | sed 's/://g' | sed 's/_/-/g')"
2025-05-05 18:21:57 +02:00
diff_url="https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/${commit_id}~1..$commit_id"
2025-11-10 08:20:56 +01:00
echo " - [$summary](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/$commit_id/README.md) ([doc]($url_doc) - [diff]($diff_url))" >> summary.md
2025-05-05 18:21:57 +02:00
cp "summary_total.md" "$DEST"
2025-11-09 14:20:04 +01:00
BEFORE=$PWD
2025-11-02 20:39:39 +01:00
cd "$i/structural_files"
2024-07-21 11:27:47 +02:00
if [ -d firefox ]; then
for j in $(ls firefox/*.yml 2>/dev/null); do
2025-11-10 08:20:56 +01:00
cp -v "$j" "$DEST/$j"
2024-07-21 11:27:47 +02:00
done
fi
if [ -d foxyproxy ]; then
mkdir -p $DEST/foxyproxy
for j in $(ls foxyproxy/*.yml 2>/dev/null); do
2025-11-10 08:20:56 +01:00
cp -v "$j" "$DEST/$j"
2024-07-21 11:27:47 +02:00
done
fi
2026-03-08 07:49:25 +01:00
if [ -d ../types ]; then
mkdir -p $DEST/types
for j in $(ls -d ../types/* 2>/dev/null); do
cp -va "$j" "$DEST/types/"
done
2026-06-14 09:33:16 +02:00
has_new_type="true"
else
has_new_type="false"
2026-03-08 07:49:25 +01:00
fi
2025-11-09 14:20:04 +01:00
cd $DEST
tree -H $TUTO_ROOT/$commit_id/ -P "*.yml" > tree.html
cd - > /dev/null
2026-03-08 07:49:25 +01:00
cp -v NODISPLAY DISPLAY_* "$DEST/" 2> /dev/null || true
2024-07-21 11:27:47 +02:00
cp -f ../README.md "$DEST"
if [ -d ../config ]; then
2026-06-14 09:33:16 +02:00
cp -vaL ../config "$DEST"
2024-07-21 11:27:47 +02:00
fi
2025-11-09 14:20:04 +01:00
msg="[tutorial $commit_id] $(cat ../README.md)"
2024-07-21 11:27:47 +02:00
[ -e ../firefox.png ] && cp ../firefox.png "$DEST"
[ -e ../foxyproxy.png ] && cp ../foxyproxy.png "$DEST"
2026-03-08 07:49:25 +01:00
[ -e ../namespace ] && cp ../namespace "$DEST"
2025-11-09 14:20:04 +01:00
cd $BEFORE
2024-07-21 11:27:47 +02:00
cd "$DEST"
2025-05-05 18:21:57 +02:00
#
2026-06-14 09:33:16 +02:00
echo "- [List of all the tutorial steps](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/branch/$VERSION/README.md)" > summary_before.md
2026-03-08 07:49:25 +01:00
if [ -n "$old_commit_id" ]; then
2026-06-14 09:33:16 +02:00
echo "- [$(echo $old_summary| sed 's/\[tutorial /\[Previous tutorial /')](https://forge.cloud.silique.fr/stove/rougail-tutorials/src/commit/$old_commit_id/README.md) ([diff]($diff_url))" >> summary_before.md
2025-05-05 18:21:57 +02:00
fi
echo "" >> summary_before.md
echo "# $summary" >> summary_before.md
echo "" >> summary_before.md
2026-06-14 09:33:16 +02:00
echo "- [Read the tutorial \"$title\" in the documentation]($url_doc)" >> summary_before.md
echo "- [View the changes in the files]($diff_url)" >> summary_before.md
2025-05-05 18:21:57 +02:00
after=$(grep "commit/$commit_id/README.md" summary_total.md -A1 | wc -l)
if [ "$after" = "2" ]; then
2026-06-14 09:33:16 +02:00
echo $(grep "commit/$commit_id/README.md" summary_total.md -A1 | tail -n 1 | sed 's/\[tutorial /\[Next tutorial /') > summary_after.md
2025-05-05 18:21:57 +02:00
fi
#
2026-06-14 09:33:16 +02:00
ENV="ROUGAILCLI_CLI.CONFIG_FILE=$BUILDER/rougailcli_common.yml"
if [ -d types ]; then
ENV="$ENV,$BUILDER/rougailcli_types.yml"
fi
2025-05-05 18:21:57 +02:00
if [ -f config/mode ]; then
mv config/mode mode
fi
2026-06-14 09:33:16 +02:00
if [ -f mode ]; then
ENV="$ENV,$BUILDER/rougailcli_mode.yml"
fi
if [ -f namespace ] || [ -d foxyproxy ]; then
ENV="$ENV,$BUILDER/rougailcli_namespace.yml"
if [ -d foxyproxy ]; then
ENV="$ENV,$BUILDER/rougailcli_namespace_foxyproxy.yml"
fi
fi
env $ENV,$BUILDER/rougailcli_documentation.yml rougail > DOCUMENTATION.md
if [ "$(cat DOCUMENTATION.md)" = "$EMPTY" ]; then rm DOCUMENTATION.md; echo "NO DOCUMENTATION"; fi
if [ -f "$BUILDER"/previous.yml ]; then
env $ENV,$BUILDER/rougailcli_documentation.yml,$BUILDER/rougailcli_changelog.yml rougail > CHANGELOG.md
if [ "$(cat CHANGELOG.md)" = "$EMPTY" ]; then rm CHANGELOG.md; fi
fi
if [ ! -f CHANGELOG.md ]; then echo "NO CHANGELOG"; fi
"$BUILDER"/build.py "$BUILDER" "$commit_id" "$has_new_type"
2026-03-08 07:49:25 +01:00
rm -rf config/*/README.md config/*/read_write namespace config/*/invalid DISPLAY_* NODISPLAY
2025-05-05 18:21:57 +02:00
rm -rf jinja_caches summary.md summary_before.md summary_after.md summary_total.md
if [ -f mode ]; then
MODE=1
rm -f mode
else
MODE=0
fi
2025-11-09 14:20:04 +01:00
git add *.png README.md install.txt tree.html
2026-06-14 09:33:16 +02:00
git add DOCUMENTATION.md &> /dev/null || true
git add CHANGELOG.md &> /dev/null || true
2025-05-05 18:21:57 +02:00
if [ -d config ]; then
git add config
else
git status |grep -q config && git add config
fi
2026-06-14 09:33:16 +02:00
git commit -m"$summary (config and doc)" > /dev/null
2024-07-21 11:27:47 +02:00
git add .
2026-06-14 09:33:16 +02:00
git commit -am"$msg" --allow-empty > /dev/null
2025-05-05 18:21:57 +02:00
git tag -a "$commit_id" -m"format version $VERSION: $num"
if [ "$MODE" = 1 ]; then
touch mode
fi
2024-07-21 11:27:47 +02:00
cd - > /dev/null
2026-03-08 07:49:25 +01:00
old_commit_id="$commit_id"
2026-06-14 09:33:16 +02:00
old_summary="$summary"
2026-03-08 07:49:25 +01:00
# echo "pouet $i"
2026-06-14 09:33:16 +02:00
# [ "$i" = "examples/002" ] && exit 1
2026-03-08 07:49:25 +01:00
if [ -f previous.yml ]; then cp -a previous.yml previous_old.yml; fi
2024-07-21 11:27:47 +02:00
fi
done
cd "$DEST"
echo "# Description
This tutorial shows to you an example of Rougail use on how to set a proxy in the Mozilla Firefox browser.
More precisely, this tutorial aims at reproducing this [Mozilla Firefox](https://www.mozilla.org/firefox/new/) settings page:
![Firefox Proxy setting](firefox.png)
And the integration of part of the [Firefox FoxyProxy plugin](https://addons.mozilla.org/firefox/addon/foxyproxy-standard/).
The idea is to have a namespace specific to FoxyProxy and to find in it part of the settings that we will have made in the main namespace.
This is what the page looks like:
![Foxyproxy Proxy setting](foxyproxy.png)
" > README.md
2025-05-05 18:21:57 +02:00
echo '# Installation
2025-11-09 14:20:04 +01:00
To test this tutorial, you need to download this repository and install Rougail:
```bash' >> README.md
cat install.txt >> README.md
echo '```
2025-05-05 18:21:57 +02:00
' >> README.md
2024-07-21 11:27:47 +02:00
echo "# Summary
Each step is a separerate commit. You can navigate to history to discover different aspect to the Rougail format.
" >> README.md
2025-05-05 18:21:57 +02:00
cp "$BUILDER"/firefox.png .
cp "$BUILDER"/foxyproxy.png .
2024-07-21 11:27:47 +02:00
cat "$BUILDER"/summary.md >> README.md
echo >> README.md
2025-11-09 14:20:04 +01:00
rm -rf firefox foxyproxy mode install.txt tree.html
2024-07-21 11:27:47 +02:00
git add .
git commit -am"Summary"
#
git remote add origin ssh://git@forge.cloud.silique.fr:2222/stove/rougail-tutorials.git
2025-05-05 18:21:57 +02:00
git push --set-upstream origin $VERSION --force
git push --tag --force
2024-07-21 11:27:47 +02:00
2025-05-05 18:21:57 +02:00
rm -f summary.md summary_total.md
2024-07-21 11:27:47 +02:00
echo "FAIT"
exit 0