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