|
| 1 | +name: Documentation Build |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + documentation_tag: |
| 10 | + type: string |
| 11 | + required: false |
| 12 | + default: "latest" |
| 13 | + description: "Label of the documentation" |
| 14 | + publish_to_prod: |
| 15 | + type: boolean |
| 16 | + default: true |
| 17 | + publish_to_dev: |
| 18 | + type: boolean |
| 19 | + default: true |
| 20 | + pull_request: |
| 21 | + types: [opened, synchronize, reopened] |
| 22 | + branches: |
| 23 | + - main |
| 24 | + - 'v*-branch' |
| 25 | + paths: |
| 26 | + - '.github/workflows/doc-build.yml' |
| 27 | + - '.github/workflows/doc-publish.yml' |
| 28 | + - '**.rst' |
| 29 | + - 'doc/**' |
| 30 | + - "include/**" |
| 31 | + push: |
| 32 | + branches: |
| 33 | + - main |
| 34 | + - 'v*-branch' |
| 35 | + tags: |
| 36 | + - v* |
| 37 | + |
| 38 | +env: |
| 39 | + DOXYGEN_VERSION: 1.12.0 |
| 40 | + |
| 41 | +concurrency: |
| 42 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 43 | + cancel-in-progress: true |
| 44 | + |
| 45 | +jobs: |
| 46 | + build: |
| 47 | + runs-on: ubuntu-24.04 |
| 48 | + steps: |
| 49 | + - name: Checkout |
| 50 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 51 | + with: |
| 52 | + ref: ${{ github.event.pull_request.head.sha }} |
| 53 | + |
| 54 | + - name: Install system dependencies |
| 55 | + run: | |
| 56 | + wget --no-verbose "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz" |
| 57 | + sudo tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz -C /opt |
| 58 | + echo "/opt/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH |
| 59 | +
|
| 60 | + - name: Set up Python |
| 61 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 62 | + with: |
| 63 | + python-version: 3.12 |
| 64 | + cache: pip |
| 65 | + cache-dependency-path: doc/requirements.txt |
| 66 | + pip-install: | |
| 67 | + -r doc/requirements.txt |
| 68 | +
|
| 69 | + - name: Build |
| 70 | + working-directory: doc |
| 71 | + run: | |
| 72 | + doxygen |
| 73 | + sphinx-build -M html . build |
| 74 | +
|
| 75 | + - name: Check version |
| 76 | + run: | |
| 77 | + VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$" |
| 78 | + if [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then |
| 79 | + VERSION=${BASH_REMATCH[1]} |
| 80 | + elif [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then |
| 81 | + VERSION="latest" |
| 82 | + elif [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 83 | + VERSION="pr-${{ github.event.number }}" |
| 84 | + fi |
| 85 | + echo "VERSION=${VERSION}" |
| 86 | + echo "VERSION=${VERSION}" >> "$GITHUB_ENV" |
| 87 | +
|
| 88 | + - name: Prepare Azure upload |
| 89 | + run: | |
| 90 | + PUBLISH="$PWD/publish" |
| 91 | + mkdir -p "$PUBLISH" |
| 92 | +
|
| 93 | + MONITOR="monitor_${{ github.run_id }}.txt" |
| 94 | +
|
| 95 | + # Create documentation upload files |
| 96 | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 97 | + ARCHIVE="legacy-addon-serial_modem-pr-${{ github.event.number }}.zip" |
| 98 | + echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}" |
| 99 | + echo "${{ github.event.number }}" > pr.txt |
| 100 | + else |
| 101 | + ARCHIVE="legacy-addon-serial_modem-${VERSION}.zip" |
| 102 | + echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}" |
| 103 | + fi |
| 104 | +
|
| 105 | + pushd "doc/build/html" |
| 106 | + zip -rq "${ARCHIVE}" . |
| 107 | + mv "${ARCHIVE}" "$PUBLISH" |
| 108 | + popd |
| 109 | +
|
| 110 | + mv "${MONITOR}" "$PUBLISH" |
| 111 | + if [[ -f pr.txt ]]; then mv pr.txt "$PUBLISH"; fi |
| 112 | +
|
| 113 | + - name: Prepare Zoomin upload |
| 114 | + if: ${{ github.event_name == 'push' }} |
| 115 | + run: | |
| 116 | + PUBLISH="$PWD/publish" |
| 117 | + mkdir -p "$PUBLISH" |
| 118 | +
|
| 119 | + OUTDIR=doc/build/html |
| 120 | + ARCHIVE="addon-serial_modem_$VERSION.zip" |
| 121 | +
|
| 122 | + cp doc/custom.properties "$OUTDIR/custom.properties" |
| 123 | + sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/custom.properties" |
| 124 | +
|
| 125 | + cp doc/tags.yml "$OUTDIR/tags.yml" |
| 126 | + sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/tags.yml" |
| 127 | +
|
| 128 | + pushd "$OUTDIR" |
| 129 | + zip -rq "$ARCHIVE" . |
| 130 | + mv "$ARCHIVE" "$PUBLISH" |
| 131 | + popd |
| 132 | +
|
| 133 | + - name: Store |
| 134 | + if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }} |
| 135 | + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 136 | + with: |
| 137 | + name: docs |
| 138 | + retention-days: 5 |
| 139 | + path: | |
| 140 | + publish/* |
0 commit comments