From fa9908413badea0215ffc51f4a37963d98fd15af Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 21 Aug 2023 15:40:03 +0200 Subject: [PATCH 1/8] minimal first version bump script --- documentation/bump_versions.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 documentation/bump_versions.sh diff --git a/documentation/bump_versions.sh b/documentation/bump_versions.sh new file mode 100755 index 0000000000..507af1492e --- /dev/null +++ b/documentation/bump_versions.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# this takes two args: platform release version and wallet release version. +# it then uses sed to bump them in the three book.toml files. +# +# e.g if the upcoming platform release was v1.1.29 and the release version 1.2.9 you'd run this as: +# `./bump_versions.sh "1.1.29" "1.2.9"` + +# array of project dirs +declare -a projects=("docs" "dev-portal" "operators") + +## now loop through the above array sed-ing the variable values in the book.toml files +for i in "${projects[@]}" +do + # sed the vars in the book.toml file for each project + sed -i 's/platform_release_version =.*/platform_release_version = "'$1'"/' "$i"/book.toml + sed -i 's/wallet_release_version =.*/wallet_release_version = "'$2'"/' "$i"/book.toml +done \ No newline at end of file From 067a501d980ca71472d74de9493c525e699659ae Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 21 Aug 2023 15:40:14 +0200 Subject: [PATCH 2/8] added docs --- documentation/build_all_to_dist.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/documentation/build_all_to_dist.sh b/documentation/build_all_to_dist.sh index 721ed07e6a..71310bbb5e 100755 --- a/documentation/build_all_to_dist.sh +++ b/documentation/build_all_to_dist.sh @@ -1,6 +1,9 @@ #!/bin/bash - -# commands assume you run script from `nym/documentation/` +# this is a script called by the github CI and CD workflows to build all 3 docs projects +# and move them to /dist/ in the root of the monorepo. They are rsynced to various servers +# from there by the CI and CD workflows. +# +# these commands assume the script is run from `nym/documentation/` # array of project dirs declare -a projects=("docs" "dev-portal" "operators") @@ -34,4 +37,5 @@ do # cd back to ../documentation/ cd ../ done +# rename for server paths mv ../dist/docs/dev-portal ../dist/docs/developers From 5b86646bd8a3605ea6a9318892030c7505ef4df4 Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 21 Aug 2023 15:55:38 +0200 Subject: [PATCH 3/8] added optional arg for updating minimum rust version --- documentation/bump_versions.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/documentation/bump_versions.sh b/documentation/bump_versions.sh index 507af1492e..123705ee7a 100755 --- a/documentation/bump_versions.sh +++ b/documentation/bump_versions.sh @@ -4,6 +4,9 @@ # # e.g if the upcoming platform release was v1.1.29 and the release version 1.2.9 you'd run this as: # `./bump_versions.sh "1.1.29" "1.2.9"` +# +# you can also set the minumum rust version by passing an optional 3rd argument: +# `./bump_versions.sh "1.1.29" "1.2.9" "1.67"` # array of project dirs declare -a projects=("docs" "dev-portal" "operators") @@ -12,6 +15,12 @@ declare -a projects=("docs" "dev-portal" "operators") for i in "${projects[@]}" do # sed the vars in the book.toml file for each project + echo "setting platform and wallet versions in $i" sed -i 's/platform_release_version =.*/platform_release_version = "'$1'"/' "$i"/book.toml sed -i 's/wallet_release_version =.*/wallet_release_version = "'$2'"/' "$i"/book.toml + if [ "$3" ] + then + echo "setting minimum rust version in $i" + sed -i 's/minimum_rust_version = .*/minimum_rust_version = "'$3'"/' "$i"/book.toml + fi done \ No newline at end of file From 5a0255fd017571668da28099715a925593b7c5a1 Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 21 Aug 2023 16:30:16 +0200 Subject: [PATCH 4/8] added some checks --- documentation/build_all_to_dist.sh | 72 ++++++++++++++++-------------- documentation/bump_versions.sh | 41 +++++++++++------ 2 files changed, 66 insertions(+), 47 deletions(-) diff --git a/documentation/build_all_to_dist.sh b/documentation/build_all_to_dist.sh index 71310bbb5e..13e5f549e5 100755 --- a/documentation/build_all_to_dist.sh +++ b/documentation/build_all_to_dist.sh @@ -1,41 +1,45 @@ #!/bin/bash # this is a script called by the github CI and CD workflows to build all 3 docs projects # and move them to /dist/ in the root of the monorepo. They are rsynced to various servers -# from there by the CI and CD workflows. -# -# these commands assume the script is run from `nym/documentation/` +# from there by subsequent workflow tasks. # array of project dirs declare -a projects=("docs" "dev-portal" "operators") -## now loop through the above array -for i in "${projects[@]}" -do - # cd to project dir - cd "./$i" && - # little sanity checks - echo $(pwd) && echo $(mdbook --version) && - # clean old book - echo "cleaning old book" - rm -rf ./book/ - # build book - mdbook build - # check for destination, if ! then mkdir & check again else echo thumbs up - if [ ! -d ../../dist/docs/$i ]; then - echo "dest doesn't exist: creating dir" - mkdir -p ../../dist/docs/$i - fi - if [ -d ../../dist/docs/$i ]; then - echo "cp destination exists, all good" - fi - # clean old dist/$i - rm -rf ../../dist/docs/$i - # move newly rendered book/ to dist - rsync -r ./book/html/ ../../dist/docs/$i - # sanity check - ls -laF ../../dist/docs/ - # cd back to ../documentation/ - cd ../ -done -# rename for server paths -mv ../dist/docs/dev-portal ../dist/docs/developers +# check you're calling from the right place +if [ $(pwd | awk -F/ '{print $NF}') != "documentation" ] +then + echo "failure: please run script from documentation/" +else + for i in "${projects[@]}" + do + # cd to project dir + cd "./$i" && + # little sanity checks + echo $(pwd) && echo $(mdbook --version) && + # clean old book + echo "cleaning old book" + rm -rf ./book/ + # build book + mdbook build + # check for destination, if ! then mkdir & check again else echo thumbs up + if [ ! -d ../../dist/docs/$i ]; then + echo "dest doesn't exist: creating dir" + mkdir -p ../../dist/docs/$i + fi + if [ -d ../../dist/docs/$i ]; then + echo "cp destination exists, all good" + fi + # clean old dist/$i + rm -rf ../../dist/docs/$i + # move newly rendered book/ to dist + rsync -r ./book/html/ ../../dist/docs/$i + # sanity check + ls -laF ../../dist/docs/ + # cd back to ../documentation/ + cd ../ + done + # rename for server paths + mv ../dist/docs/dev-portal ../dist/docs/developers +fi + diff --git a/documentation/bump_versions.sh b/documentation/bump_versions.sh index 123705ee7a..a3ddeb56b5 100755 --- a/documentation/bump_versions.sh +++ b/documentation/bump_versions.sh @@ -11,16 +11,31 @@ # array of project dirs declare -a projects=("docs" "dev-portal" "operators") -## now loop through the above array sed-ing the variable values in the book.toml files -for i in "${projects[@]}" -do - # sed the vars in the book.toml file for each project - echo "setting platform and wallet versions in $i" - sed -i 's/platform_release_version =.*/platform_release_version = "'$1'"/' "$i"/book.toml - sed -i 's/wallet_release_version =.*/wallet_release_version = "'$2'"/' "$i"/book.toml - if [ "$3" ] - then - echo "setting minimum rust version in $i" - sed -i 's/minimum_rust_version = .*/minimum_rust_version = "'$3'"/' "$i"/book.toml - fi -done \ No newline at end of file +# if called with no args then exit +if [[ $# -eq 0 ]] ; then + echo 'calling with no args: failure' + exit 0 +fi + +# check you're calling from the right place +if [ $(pwd | awk -F/ '{print $NF}') != "documentation" ] +then + echo "failure: please run script from documentation/" +else + ## now loop through the above array sed-ing the variable values in the book.toml files + for i in "${projects[@]}" + do + # sed the vars in the book.toml file for each project + echo "setting platform and wallet versions in $i" + sed -i 's/platform_release_version =.*/platform_release_version = "'$1'"/' "$i"/book.toml + if [ "$2" ] + then + sed -i 's/wallet_release_version =.*/wallet_release_version = "'$2'"/' "$i"/book.toml + fi + if [ "$3" ] + then + echo "setting minimum rust version in $i" + sed -i 's/minimum_rust_version = .*/minimum_rust_version = "'$3'"/' "$i"/book.toml + fi + done +fi From b6febc51a38cafbb2d6b4436e1f31c9e18be6fad Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 21 Aug 2023 16:42:34 +0200 Subject: [PATCH 5/8] added check for # of args --- documentation/bump_versions.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/documentation/bump_versions.sh b/documentation/bump_versions.sh index a3ddeb56b5..b2f5e64a36 100755 --- a/documentation/bump_versions.sh +++ b/documentation/bump_versions.sh @@ -11,9 +11,11 @@ # array of project dirs declare -a projects=("docs" "dev-portal" "operators") -# if called with no args then exit -if [[ $# -eq 0 ]] ; then - echo 'calling with no args: failure' +# check number of args passed +if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; +then + echo "failure: please pass at least 2 and at most 3 args: " + echo "./bump_version.sh [OPTIONAL]" exit 0 fi @@ -26,15 +28,12 @@ else for i in "${projects[@]}" do # sed the vars in the book.toml file for each project - echo "setting platform and wallet versions in $i" + echo "setting platform and wallet versions in $i/" sed -i 's/platform_release_version =.*/platform_release_version = "'$1'"/' "$i"/book.toml - if [ "$2" ] - then - sed -i 's/wallet_release_version =.*/wallet_release_version = "'$2'"/' "$i"/book.toml - fi + sed -i 's/wallet_release_version =.*/wallet_release_version = "'$2'"/' "$i"/book.toml if [ "$3" ] then - echo "setting minimum rust version in $i" + echo "setting minimum rust version in $i/" sed -i 's/minimum_rust_version = .*/minimum_rust_version = "'$3'"/' "$i"/book.toml fi done From 8004d54d5efbfb256a43efe312fbb2a5110b7da3 Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 21 Aug 2023 16:43:52 +0200 Subject: [PATCH 6/8] added exit to conditional failure --- documentation/bump_versions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/bump_versions.sh b/documentation/bump_versions.sh index b2f5e64a36..6201119a77 100755 --- a/documentation/bump_versions.sh +++ b/documentation/bump_versions.sh @@ -23,6 +23,7 @@ fi if [ $(pwd | awk -F/ '{print $NF}') != "documentation" ] then echo "failure: please run script from documentation/" + exit 0 else ## now loop through the above array sed-ing the variable values in the book.toml files for i in "${projects[@]}" From ffac0a1f92e7c9ba78320881473e4612db1addf5 Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Mon, 21 Aug 2023 18:01:04 +0200 Subject: [PATCH 7/8] updated readme w info re: scripts --- documentation/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/documentation/README.md b/documentation/README.md index e074f7cdfe..9e490e4d57 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -1,7 +1,13 @@ # Documentation +## Doc projects +Each directory contains a readme with more information about running and contributing to the projects. Each is built with [`mdbook`](https://rust-lang.github.io/mdBook/index.html) - use `mdbook serve` to build and serve them (defaults to `localhost:3000`). * `docs` contains technical documentation hosted at [https://nymtech.net/docs](https://nymtech.net/docs) * `dev-portal` contains developer documentation hosted at [https://nymtech.net/developers](https://nymtech.net/developers) * `operators` contains node setup and maintenance guides hosted at [https://nymtech.net/operators](https://nymtech.net/operators) -Each directory contains a readme with more information about running and contributing to the projects. Each is built with [`mdbook`](https://rust-lang.github.io/mdBook/index.html) - use `mdbook serve` to build and serve them (defaults to `localhost:3000`). +## Scripts +* `bump_versions.sh` allows you to update the `platform_release_version` and `wallet_release_version` variables in the `book.toml` of each mdbook project at once. You can also optionally update the `minimum_rust_version` as well. Helpful for lazy-updating when cutting a new version of the docs. + * `build_all_to_dist.sh` is used by the `ci-dev.yml` and `cd-dev.yml` scripts for building all mdbook projects and moving the rendered html to `../dist/` to be rsynced with various servers. + + From 5d454f2efcb2a0cf5d8ba3345b004f96e175ff63 Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Tue, 22 Aug 2023 10:03:08 +0200 Subject: [PATCH 8/8] fixed issue with already existing directory during mv --- documentation/build_all_to_dist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/build_all_to_dist.sh b/documentation/build_all_to_dist.sh index 13e5f549e5..b414e92df6 100755 --- a/documentation/build_all_to_dist.sh +++ b/documentation/build_all_to_dist.sh @@ -40,6 +40,6 @@ else cd ../ done # rename for server paths + rm -rf ../dist/docs/developers mv ../dist/docs/dev-portal ../dist/docs/developers fi -