-
Notifications
You must be signed in to change notification settings - Fork 39
189 lines (153 loc) · 7.23 KB
/
docs.yml
File metadata and controls
189 lines (153 loc) · 7.23 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Documentation Build
on: [push, pull_request]
env:
DOXYGEN_VERSION: 1.12.0
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
path: sdk-nrf-bm/nrf-bm
- name: Install system dependencies
run: |
sudo apt-get install -y cmake ninja-build
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: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: 3.12
cache: pip
cache-dependency-path: sdk-nrf-bm/nrf-bm/doc/requirements.txt
- name: Install Python dependencies
working-directory: sdk-nrf-bm/nrf-bm
run: |
pip install west
pip install -r doc/requirements.txt
- name: West update
working-directory: sdk-nrf-bm/nrf-bm
run: |
west init -l .
west update -o=--depth=1 -n
west zephyr-export
- name: Build
working-directory: sdk-nrf-bm/nrf-bm
run: |
cmake -G Ninja -S doc -B doc/_build
cmake --build doc/_build
- 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
working-directory: sdk-nrf-bm/nrf-bm/doc/_build/html
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"
else
ARCHIVE="legacy-ncs-${VERSION}.zip"
fi
zip -rq "${ARCHIVE}" .
# Create monitor/pr files after zip to avoid including them in the archive
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}"
echo "${{ github.event.number }}" > pr.txt
else
echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}"
fi
- name: Prepare Zoomin upload
if: ${{ github.event_name == 'push' }}
working-directory: sdk-nrf-bm/nrf-bm
run: |
PUBLISH="$PWD/publish"
mkdir -p "$PUBLISH"
# Doxygen APIs combined with Sphinx
declare -a SPHINX_DOXYGEN=("nrf-bm")
# Doxygen APIs standalone
declare -a DOXYGEN=("s115_nrf54l15" "s145_nrf54l15" "s115_nrf54lm20" "s145_nrf54lm20" "s115_nrf54ls05" "s145_nrf54ls05" "s115_nrf54lv10" "s145_nrf54lv10")
mkdir doc/_build/html-doxygen
for docset in "${SPHINX_DOXYGEN[@]}"; do
OUTDIR=doc/_build/html-doxygen/$docset-apis
mv doc/_build/html/$docset/doxygen/html "$OUTDIR"
# Populate custom.properties, tags.yml
cp doc/_zoomin/$docset.apis.custom.properties "$OUTDIR/custom.properties"
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/custom.properties"
cp doc/_zoomin/$docset.apis.tags.yml "$OUTDIR/tags.yml"
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/tags.yml"
# Patch links from Sphinx to other Doxygen APIs (combined)
find doc/_build/html/$docset -type f -name "*.html" -exec sed -ri "/href=\"([^\"]+)\/([a-z]+)\/doxygen\/html\/([^\"]+)\"/{s//href=\"\/bundle\/\1\/\2-apis-$VERSION\/page\/\3\"/g; :a s/__/_/g;ta; }" {} \;
for doxset in "${DOXYGEN[@]}"; do
# Patch links from Sphinx to other Doxygen APIs (standalone)
find doc/_build/html/$docset -type f -name "*.html" -exec sed -ri "/href=\"([^\"]+)\/$doxset\/html\/([^\"]+)\"/{s//href=\"\/bundle\/\1\/$doxset-apis-$VERSION\/page\/\2\"/g; :a s/__/_/g;ta; }" {} \;
done
# Patch links from Sphinx to same docset Doxygen APIs
find doc/_build/html/$docset -type f -name "*.html" -exec sed -ri "/href=\"([^\"]+)\/doxygen\/html\/([^\"]+)\"/{s//href=\"\/bundle\/$docset-apis-$VERSION\/page\/\2\"/g; :a s/__/_/g;ta; }" {} \;
pushd "$OUTDIR"
ARCHIVE="$docset-apis-$VERSION.zip"
zip -rq "$ARCHIVE" .
mv "$ARCHIVE" "$PUBLISH"
popd
done
for docset in "${DOXYGEN[@]}"; do
OUTDIR=doc/_build/html-doxygen/$docset-apis
mv doc/_build/html/$docset/html "$OUTDIR"
# Populate custom.properties, tags.yml
cp doc/_zoomin/$docset.apis.custom.properties "$OUTDIR/custom.properties"
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/custom.properties"
cp doc/_zoomin/$docset.apis.tags.yml "$OUTDIR/tags.yml"
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/tags.yml"
pushd "$OUTDIR"
ARCHIVE="$docset-apis-$VERSION.zip"
zip -rq "$ARCHIVE" .
mv "$ARCHIVE" "$PUBLISH"
popd
done
# nRF Bare Metal
OUTDIR=doc/_build/html
# Populate custom.properties, tags.yml
cp doc/_zoomin/nrf-bm.custom.properties "$OUTDIR/custom.properties"
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/custom.properties"
cp doc/_zoomin/nrf-bm.tags.yml "$OUTDIR/tags.yml"
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/tags.yml"
ARCHIVE="nrf-bm-$VERSION.zip"
pushd "$OUTDIR"
zip -rq "$ARCHIVE" .
mv "$ARCHIVE" "$PUBLISH"
popd
- name: Find nRF Connect SDK Bare Metal Edited Documents
working-directory: sdk-nrf-bm/nrf-bm
run: |
COMMENT="comment.txt"
PREFIX="https://ncsbmdoc.z6.web.core.windows.net/ncs-bm/PR-${{ github.event.pull_request.number }}/"
echo "You can find the documentation preview for this PR [here](${PREFIX})." >> $COMMENT
- name: Stage files for publish
working-directory: sdk-nrf-bm/nrf-bm
run: |
mkdir -p publish
cp doc/_build/html/monitor_*.txt publish/
cp doc/_build/html/*.zip publish/
if [[ -f doc/_build/html/pr.txt ]]; then cp doc/_build/html/pr.txt publish/; fi
cp comment.txt publish/
- 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@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
with:
name: docs
retention-days: 5
path: |
sdk-nrf-bm/nrf-bm/publish/*