diff --git a/.github/workflows/deploy_documentation.yml b/.github/workflows/deploy_documentation.yml new file mode 100644 index 00000000..fb300580 --- /dev/null +++ b/.github/workflows/deploy_documentation.yml @@ -0,0 +1,39 @@ +name: Deploy documentation to www.etlcpp.com + +on: + push: + branches: + - master + + workflow_dispatch: + +jobs: + build_deploy: + name: build and deploy + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v3 + with: + hugo-version: '0.147.1' + extended: true + + - name: Build + working-directory: hugo + run: hugo --minify --cleanDestinationDir --baseURL "https://www.etlcpp.com/" + + # Deploys the site via the deploy script in the ci directory + - name: Deploy + run: source $GITHUB_WORKSPACE/scripts/deploy_documentation.sh + env: + ACTIONS_DEPLOY_KEY: ${{ secrets.DOCS_BDEPLOY_KEY }} + SSH_USERNAME: ${{ secrets.DOCS_SSH_USER }} + SERVER_ADDRESS: ${{ secrets.DOCS_SSH_SERVER }} + SERVER_DESTINATION: ${{ secrets.DOCS_DEST_DIR }} + SSH_PORT: ${{ secrets.DOCS_SSH_PORT }} diff --git a/docs/_index.md b/docs/_index.md index 7dca7869..e6f75a2e 100644 --- a/docs/_index.md +++ b/docs/_index.md @@ -49,6 +49,9 @@ type: hextra-home +## Version +This documents version **{{< version >}}**. + ## Motivation C++ is a powerful language for embedded systems development, with templates offering a great deal of flexibility and type safety. While the C++ Standard Library provides a wealth of well-tested functionality, it’s often not well suited to environments with strict deterministic behavior and limited resources. diff --git a/docs/pseudo-containers/bresenham_line.md b/docs/pseudo-containers/bresenham_line.md index eca08b16..d4ca5a20 100644 --- a/docs/pseudo-containers/bresenham_line.md +++ b/docs/pseudo-containers/bresenham_line.md @@ -2,6 +2,10 @@ title: "bresenham_line" --- +{{< callout type="info">}} + Headers: `bresenham_line.h` +{{< /callout >}} + A 'pseudo' container that generates coordinates on a line between two points using the [Bresenham line algorithm](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm). The class has an STL-like API and is a forward iterator type container. diff --git a/hugo/assets/version.txt b/hugo/assets/version.txt new file mode 100644 index 00000000..1055985e --- /dev/null +++ b/hugo/assets/version.txt @@ -0,0 +1 @@ +20.47.1 diff --git a/hugo/layouts/shortcodes/version.html b/hugo/layouts/shortcodes/version.html new file mode 100644 index 00000000..1ddd812f --- /dev/null +++ b/hugo/layouts/shortcodes/version.html @@ -0,0 +1,3 @@ +{{ with resources.Get "version.txt" }} + {{ .Content | strings.TrimSpace }} +{{ end }} \ No newline at end of file diff --git a/scripts/deploy_documentation.sh b/scripts/deploy_documentation.sh new file mode 100755 index 00000000..a29c84b6 --- /dev/null +++ b/scripts/deploy_documentation.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +# Set up SSH +mkdir -p ~/.ssh +echo "$ACTIONS_DEPLOY_KEY" > ~/.ssh/deploy_key +chmod 600 ~/.ssh/deploy_key + +# Add server to known hosts +ssh-keyscan -p "$SSH_PORT" "$SERVER_ADDRESS" >> ~/.ssh/known_hosts + +# Deploy using rsync over SSH +rsync -avz --delete \ + -e "ssh -i ~/.ssh/deploy_key -p $SSH_PORT" \ + hugo/public/ \ + "$SSH_USERNAME@$SERVER_ADDRESS:$SERVER_DESTINATION" \ No newline at end of file diff --git a/scripts/update_release.py b/scripts/update_release.py index 9a56418c..157c9b47 100644 --- a/scripts/update_release.py +++ b/scripts/update_release.py @@ -1,10 +1,10 @@ - + import shutil import os # Get the current path of the script script_dir = os.path.dirname(os.path.abspath(__file__)) - + # Get the root folder of the ETL etl_dir = os.path.abspath(os.path.join(script_dir, os.pardir)) @@ -14,6 +14,9 @@ include_dir = os.path.join(etl_dir, 'include') # Get the ETL headers folder headers_dir = os.path.join(include_dir, 'etl') +# Get the Hugo folder +hugo_dir = os.path.join(etl_dir, 'hugo') + # Get the Arduino folder arduino_dir = os.path.join(etl_dir, 'arduino') @@ -54,6 +57,7 @@ def create_arduino_variant(): print('etl_dir = ', etl_dir) print('include_dir = ', include_dir) print('headers_dir = ', headers_dir) + print('hugo_dir = ', hugo_dir) print('arduino_dir = ', arduino_dir) print('examples_dir = ', arduino_examples_dir) print('common_dir = ', common_dir) @@ -121,7 +125,7 @@ def get_version(): version_file = os.path.join(etl_dir, 'version.txt') print('') print('version_file = ', version_file) - + with open(version_file) as f: version = f.read().splitlines() @@ -135,10 +139,10 @@ def update_version_h(): print('Creating version.h') version_h = os.path.join(headers_dir, 'version.h') - + with open(version_h) as f: text = f.read().splitlines() - + search_major = '#define ETL_VERSION_MAJOR ' search_minor = '#define ETL_VERSION_MINOR ' search_patch = '#define ETL_VERSION_PATCH ' @@ -148,19 +152,19 @@ def update_version_h(): length_patch = len(search_patch) for i in range(len(text) - 1): - + index = text[i].find(search_major) if index != -1: text[i] = text[i][index:length_major] + major_version print(text[i]) - + index = text[i].find(search_minor) if index != -1: text[i] = text[i][index:length_minor] + minor_version print(text[i]) index = text[i].find(search_patch) - if index != -1: + if index != -1: text[i] = text[i][index:length_patch] + patch_version print(text[i]) @@ -169,17 +173,31 @@ def update_version_h(): f.write(line) f.write('\n') +#------------------------------------------------------------------------------ +def update_hugo_version_txt(): + print('') + print('Copying version.txt to hugo/assets') + + src = os.path.join(etl_dir, 'version.txt') + dst = os.path.join(hugo_dir, 'assets', 'version.txt') + + try: + shutil.copyfile(src, dst) + print("Copy successful!") + except PermissionError: + print(f"Permission denied. Check if the file is open or locked.") + #------------------------------------------------------------------------------ def update_library_json(filename): print('') print('Creating %s' % filename) - + with open(filename) as f: text = f.read().splitlines() - + search = 'version' - for i in range(len(text) - 1): + for i in range(len(text) - 1): index = text[i].find(search) if index != -1: text[i] = ' \"version\": \"' + full_version + '\",' @@ -196,10 +214,10 @@ def update_library_properties(filename): with open(filename, 'r') as f: text = f.read().splitlines() - + search = 'version' - for i in range(len(text) - 1): + for i in range(len(text) - 1): index = text[i].find(search) if index != -1: text[i] = 'version=' + full_version @@ -224,7 +242,8 @@ def update_versions(): print("Version = %s.%s.%s" % (major_version, minor_version, patch_version )) update_version_h() - + update_hugo_version_txt() + update_library_json(os.path.join(etl_dir, 'library.json')) update_library_json(os.path.join(arduino_dir, 'library-arduino.json'))