Skip to content

Commit

Permalink
Merge pull request #83 from gematik/feature/improve-build-script
Browse files Browse the repository at this point in the history
Script checks for changes in pumls
  • Loading branch information
florianschoffke authored Aug 31, 2023
2 parents 64680da + 3bdac06 commit e18ef2a
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions resources/scripts/build_with_replace_includes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,46 @@ if ! grep -q "$required_asciidoctor_diagram_version" <<<"$actual_asciidoctor_dia
exit 1
fi

# RUN_1: creates images from the puml files and will store them in /puml/images
echo "Creating puml images"
# STAGE_1: creates images from the puml files and will store them in /puml/images

# prepare
cd "$(dirname "$0")" || exit
rm ../../images/puml_*
# rm ../../images/puml_*

# loop through all puml files and create the image
for filename in $(find ../../puml -name '*.puml'); do

filebase=$(basename -- "$filename") # test.adoc

name="${filebase%.*}" # test

pumlPath=../puml/${name}.puml
newFileRoot=../puml/${name}
newFileName=${newFileRoot//-source/}
echo "Creating Puml ${name}"
tempAdocFile=../../docs_sources/${name}.adoc
if ! git diff --quiet -- "$filename"; then
echo "$filebase has been modified. Creating Puml"

pumlPath=../puml/${name}.puml
newFileRoot=../puml/${name}
newFileName=${newFileRoot//-source/}
echo "Creating Puml ${name}"

tempAdocFile=../../docs_sources/${name}.adoc

# creates a temporary adoc file in order to render with asciidoctor-diagram
touch ${tempAdocFile}
echo "[plantuml, target=../../images/puml_${name}, format=png]
# creates a temporary adoc file in order to render with asciidoctor-diagram
touch ${tempAdocFile}
echo "[plantuml, target=../../images/puml_${name}, format=png]
....
include::${pumlPath}[]
...." >${tempAdocFile}
asciidoctor -r asciidoctor-diagram -o ../puml/$newFileName ../../docs_sources/${name}.adoc
rm ../../docs_sources/${name}.adoc
asciidoctor -r asciidoctor-diagram -o ../puml/$newFileName ../../docs_sources/${name}.adoc
rm ../../docs_sources/${name}.adoc
fi

done

# cleanup temp files
rm -r ../puml
if [ -d "../puml" ]; then
rm -r ../puml
fi

# RUN_2 this creates new adoc files in /docs/resources
echo "Creating source files"
# STAGE_2 this creates new adoc files in /docs/resources

for filename in $(find ../../docs_sources -name '*.adoc'); do
newFileName=${filename//-source/}
Expand Down

0 comments on commit e18ef2a

Please sign in to comment.