Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 0 additions & 116 deletions .github/workflows/doc-build-and-publish-zoomin.yml

This file was deleted.

148 changes: 148 additions & 0 deletions .github/workflows/doc-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Documentation Build

permissions:
contents: read

on:
workflow_dispatch:
inputs:
documentation_tag:
type: string
required: false
default: "latest"
description: "Label of the documentation"
publish_to_prod:
type: boolean
default: true
publish_to_dev:
type: boolean
default: true
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- 'v*-branch'
paths:
- '.github/workflows/doc-build.yml'
- '.github/workflows/doc-publish.yml'
- '**.rst'
- 'doc/**'
- "include/**"
push:
branches:
- main
- 'v*-branch'
tags:
- v*

env:
DOXYGEN_VERSION: 1.12.0

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
doc-build-and-publish:
env:
ARCHIVE: "addon-serial_modem-${{inputs.documentation_tag}}.zip"

runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip

- name: Install Python dependencies
working-directory: doc
run: |
python3 -m pip install -r requirements.txt

- name: Install Doxygen
run: |
wget --no-verbose "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
sudo tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt
echo "/opt/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH

- name: Build documentation
working-directory: doc
run: |
doxygen
sphinx-build -M html . build

cp custom.properties build/html
sed -i 's/__VERSION__/'"${{inputs.documentation_tag}}"'/g' build/html/custom.properties

cp tags.yml build/html
sed -i 's/__VERSION__/'"${{inputs.documentation_tag}}"'/g' build/html/tags.yml

cd build/html

zip -rq "${{env.ARCHIVE}}" .
ls -lah .
pwd

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: doc-build
if-no-files-found: error
retention-days: 2
path: |
doc/build/html/${{env.ARCHIVE}}

- name: Check version
run: |
VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$"
if [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then
VERSION=${BASH_REMATCH[1]}
elif [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then
VERSION="latest"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
VERSION="pr-${{ github.event.number }}"
fi
echo "VERSION=${VERSION}"
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"

- name: Prepare Azure upload
run: |

PUBLISH="$PWD/publish"
mkdir -p "$PUBLISH"

MONITOR="monitor_${{ github.run_id }}.txt"

# Create documentation upload files
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
ARCHIVE="legacy-addon-serial-modem-pr-${{ github.event.number }}.zip"
echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}"
echo "${{ github.event.number }}" > pr.txt
else
ARCHIVE="legacy-addon-serial-modem-${VERSION}.zip"
echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}"
fi

pushd "doc/build/html"
zip -rq "${ARCHIVE}" .
mv "${ARCHIVE}" "$PUBLISH"
popd

mv "${MONITOR}" "$PUBLISH"
if [[ -f pr.txt ]]; then mv pr.txt "$PUBLISH"; fi

- name: Store
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
uses: actions/upload-artifact@v4
with:
name: docs
retention-days: 5
path: |
publish/*
96 changes: 96 additions & 0 deletions .github/workflows/doc-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Documentation Publish

permissions:
contents: read
pull-requests: write

on:

workflow_run:
workflows: ["Documentation Build"]
types:
- completed

jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifacts
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6
with:
workflow: doc_build.yml
run_id: ${{ github.event.workflow_run.id }}

- name: Unzip html archive
working-directory: doc
run: |
OUTDIR=$(awk 'NR==1 { if ($3 ~ /^(latest|PR-[0-9]+|[0-9]+\.[0-9a-zA-Z\.\-]+)$/) print $3 }' monitor_*.txt)
echo "OUTDIR=$OUTDIR" >> "$GITHUB_ENV"
unzip legacy-addon-serial-modem*.zip -d $OUTDIR
find "$OUTDIR" -type l -delete

- name: Obtain PR number
if: ${{ github.event.workflow_run.event == 'pull_request' }}
working-directory: doc
run: |
if [ -f pr.txt ]; then
PR=$(head -n 1 pr.txt | tr -cd '0-9')
fi
printf 'PR=%s\n' "$PR" >> "$GITHUB_ENV"

- name: Upload to Azure storage
working-directory: doc
env:
AZCOPY_CONCURRENCY_VALUE: 1024
NCS_DOC_SAS_PRS: ${{ secrets.NCS_DOC_SAS_PRS }}
NCS_DOC_SAS_MAIN: ${{ secrets.NCS_DOC_SAS_MAIN }}
run: |
if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then
azcopy cp $OUTDIR "${{ vars.NCS_DOC_PR_STORAGE_URL }}addons/serial-modem?$NCS_DOC_SAS_PRS" --recursive=true
else
azcopy cp $OUTDIR "${{ vars.NCS_DOC_STORAGE_URL }}addons/serial-modem?$NCS_DOC_SAS_MAIN" --recursive=true
fi

- name: Find Comment
if: ${{ github.event.workflow_run.event == 'pull_request' }}
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3
id: fc
with:
issue-number: ${{ env.PR }}
comment-author: 'github-actions[bot]'
body-includes: documentation preview

- name: Create or update comment
if: ${{ github.event.workflow_run.event == 'pull_request' }}
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ env.PR }}
body: |
You can find the documentation preview for this PR [here](${{ vars.NCS_DOC_PR_HOSTING_URL }}addons/serial-modem/PR-${{ env.PR }}/).
edit-mode: replace

- name: Prepare Key
run: |
mkdir -p ~/.ssh
ssh-keyscan upload-v1.zoominsoftware.io >> ~/.ssh/known_hosts

echo "${{ secrets.ZOOMIN_KEY }}" > zoomin_key
chmod 600 zoomin_key

- name: Publish documentation - prod
if: ${{inputs.publish_to_prod}}
run: |
sftp -v -i zoomin_key nordic@upload-v1.zoominsoftware.io <<EOF
cd docs-be.nordicsemi.com/sphinx-html/incoming
put doc/build/html/${{env.ARCHIVE}}
EOF

- name: Publish documentation - dev
if: ${{inputs.publish_to_dev}}
run: |
sftp -v -i zoomin_key nordic@upload-v1.zoominsoftware.io <<EOF
cd nordic-be-dev.zoominsoftware.io/sphinx-html/incoming
put doc/build/html/${{env.ARCHIVE}}
EOF
5 changes: 5 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_ncs_theme'
html_theme_options = {
'docsets': {},
}

html_extra_path = ['versions.json']

## -- Options for Breathe ----------------------------------------------------
# https://breathe.readthedocs.io/en/latest/index.html
Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Sphinx==5.3.0
breathe==4.35.0
sphinx-ncs-theme==0.7.4
sphinx-ncs-theme<1.1
sphinx-tabs>=3.4
sphinx-togglebutton>=0.3.2
Pillow>=9.0.1
7 changes: 7 additions & 0 deletions doc/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
"2.0.99",
"2.0.0-preview1",
"1.0.1",
"1.0.0",
"0.3.0"
]
Loading