-
Notifications
You must be signed in to change notification settings - Fork 1.2k
158 lines (134 loc) · 5.4 KB
/
docbuild.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Documentation Build
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- 'v*-branch'
paths:
- '.github/workflows/docbuild.yml'
- '**.rst'
- '**/Kconfig'
- '**/sample.yaml'
- 'doc/**'
- 'applications/**'
- 'include/**'
- 'lib/**'
- 'doc/requirements.txt'
- 'scripts/tools-versions-*.yml'
- 'west.yml'
push:
branches:
- main
- 'v*-branch'
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout sources
uses: nrfconnect/action-checkout-west-update@main
- name: cache-pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-doc-pip
- name: Install packages
run: |
sudo apt update
sudo apt-get install -y ninja-build mscgen plantuml
sudo snap install yq
DOXYGEN_VERSION=$(yq ".doxygen.version" ./ncs/nrf/scripts/tools-versions-linux.yml)
wget --no-verbose "https://github.com/doxygen/doxygen/releases/download/Release_${DOXYGEN_VERSION//./_}/doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz"
tar xf doxygen-${DOXYGEN_VERSION}.linux.bin.tar.gz
echo "${PWD}/doxygen-${DOXYGEN_VERSION}/bin" >> $GITHUB_PATH
- name: Install Python dependencies
working-directory: ncs
run: |
sudo pip3 install -U setuptools wheel pip
pip3 install -r nrf/doc/requirements.txt
- name: West zephyr-export
working-directory: ncs
run: |
west zephyr-export
- name: Build documentation
working-directory: ncs/nrf
run: |
cmake -GNinja -Bdoc/_build -Sdoc
ninja -C doc/_build
- name: Check version
run: |
VERSION_REGEX="^v([0-9a-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}" >> $GITHUB_ENV
- name: Prepare legacy upload
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
working-directory: ncs/nrf
run: |
MONITOR="monitor_${{ github.run_id }}.txt"
# Create documentation upload files
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
ARCHIVE="legacy-ncs-pr-${{ github.event.number }}.zip"
echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}"
echo "${{ github.event.number }}" > pr.txt
else
if [ -z "${VERSION}" ]; then
echo "Not a release or latest, skipping publish"
exit 0
fi
ARCHIVE="legacy-ncs-${VERSION}.zip"
echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}"
fi
cd doc/_build/html
zip -rq "${ARCHIVE}" .
mv "${ARCHIVE}" ../../../
- name: Prepare Zoomin upload
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
working-directory: ncs/nrf
run: |
mkdir doc/_build/html-doxygen
# Zephyr APIs (Doxygen)
mv doc/_build/html/zephyr/doxygen/html doc/_build/html-doxygen/zephyr-apis
cp doc/_zoomin/zephyr.apis.custom.properties doc/_build/html-doxygen/zephyr-apis/custom.properties
sed -i 's/__VERSION__/'"${VERSION}"'/g' doc/_build/html-doxygen/zephyr-apis/custom.properties
cp doc/_zoomin/zephyr.apis.tags.yml doc/_build/html-doxygen/zephyr-apis/tags.yml
sed -i 's/__VERSION__/'"${VERSION}"'/g' doc/_build/html-doxygen/zephyr-apis/tags.yml
# NCS (Sphinx)
cp doc/_zoomin/ncs.custom.properties doc/_build/html/custom.properties
sed -i 's/__VERSION__/'"${VERSION}"'/g' doc/_build/html/custom.properties
cp doc/_zoomin/ncs.tags.yml doc/_build/html/tags.yml
sed -i 's/__VERSION__/'"${VERSION}"'/g' doc/_build/html/tags.yml
# Patch links from Zephyr (Sphinx) to Zephyr APIs (Doxygen)
find doc/_build/html/zephyr -type f -name "*.html" -exec \
sed -ri "/href=\"(.*)\/doxygen\/html\/(.*)\"/{s//href=\"\1\/..\/..\/..\/zephyr-apis-$VERSION\/page\/\2\"/; :a s/__/_/;ta; }" {} \;
# Prepare archives
cd doc/_build/
cd html-doxygen/zephyr-apis
ARCHIVE="zephyr-apis-${VERSION}.zip"
zip -rq "${ARCHIVE}" .
mv "${ARCHIVE}" ../../../../
cd ../../
ARCHIVE="ncs-${VERSION}.zip"
cd html
zip -rq "${ARCHIVE}" .
mv "${ARCHIVE}" ../../../
cd ..
- 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
path: |
ncs/nrf/*.zip
ncs/nrf/monitor*.txt
ncs/nrf/pr.txt