Repository navigation
222 lines (195 loc) · 8.38 KB
/
Copy pathdocumentation.yml
File metadata and controls
222 lines (195 loc) · 8.38 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Documentation
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
packages:
description: >
A JSON structure describing the packages to build.
E.g: [{"name":"esp-hal","tag":"v0.23.1"},{"name":"esp-radio","tag":"esp-radio-v0.12"}]
NOTE: You can run `cargo xtask release tag-releases` to get the json output generated for this workflow.
If you want to build all packages, leave this field empty.
required: false
server:
type: choice
description: Which server to deploy to
options:
- preview
- production
concurrency:
group: ${{ github.event_name == 'push' && 'docs-main' || format('docs-{0}', github.run_id) }}
cancel-in-progress: ${{ github.event_name == 'push' }}
env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
setup:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'release:docs')) }}
# required for this step, as stdout is captured by `hal-xtask release tag-releases`
env:
RUST_LOG: off
steps:
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
# Build the `xtask` package using the latest commit, and copy the
# resulting binary to the `~/.cargo/bin/` directory. We do this to
# avoid having to rebuild different versions of the package for
# different tags if they do not fall on the same commit, and to
# make sure that we take advantage of any subsequent updates to
# the xtask which may have happened after a release was tagged.
- name: Checkout repository
uses: actions/checkout@v6
with:
repository: esp-rs/esp-hal
- name: Build xtask
run: |
cargo build --package=esp-devtool --features=deploy-docs
cp target/debug/esp-devtool ~/.cargo/bin/hal-xtask
- name: Cache xtask for all jobs
uses: actions/upload-artifact@v6
with:
name: xtask
path: target/debug/esp-devtool
- id: setup_manual
name: Set up [manual run with specific packages]
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.packages != '' }}
run: |
input='${{ github.event.inputs.packages }}'
echo "packages=${input}" >> "$GITHUB_OUTPUT"
- id: setup_pr
name: Set up [pull request or all packages]
if: ${{ github.event_name != 'workflow_dispatch' }}
# Release PRs will ignore the tag values and just check out the latest commit
run: |
output=$(hal-xtask release tag-releases)
echo "packages=${output}" >> "$GITHUB_OUTPUT"
- id: deploy_target
name: Set deploy target
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "base_url=https://docs.espressif.com/projects/rust/" >> "$GITHUB_OUTPUT"
echo "channel=main" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event.inputs.server }}" = "production" ]; then
echo "base_url=https://docs.espressif.com/projects/rust/" >> "$GITHUB_OUTPUT"
echo "channel=" >> "$GITHUB_OUTPUT"
else
echo "base_url=https://preview-docs.espressif.com/projects/rust/" >> "$GITHUB_OUTPUT"
echo "channel=" >> "$GITHUB_OUTPUT"
fi
outputs:
packages: "${{ steps.setup_manual.outputs.packages || steps.setup_pr.outputs.packages }}"
base_url: ${{ steps.deploy_target.outputs.base_url }}
channel: ${{ steps.deploy_target.outputs.channel }}
build:
needs: setup
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'release:docs')) }}
strategy:
fail-fast: true
matrix:
packages: ${{ fromJson(needs.setup.outputs.packages) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-toolchains
with:
xtensa: "true"
xtensa-default: "true"
# xtensa-toolchain installs rustup and a basic toolchain, but doesn't install rust-src
- name: rust-src
run: rustup component add rust-src --toolchain nightly
# Checkout the tag we need to start building the docs
- name: Checkout repository
uses: actions/checkout@v6
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
repository: esp-rs/esp-hal
ref: ${{ matrix.packages.tag }}
# If running a release PR, we want to build docs for the latest commit on the released branch.
- name: Checkout repository
uses: actions/checkout@v6
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
with:
repository: esp-rs/esp-hal
- name: Download xtask
uses: actions/download-artifact@v4
with:
name: xtask
path: ~/.cargo/bin/
- name: Build documentation
run: |
chmod +x ~/.cargo/bin/esp-devtool
CHANNEL_ARGS=""
if [ -n "${{ needs.setup.outputs.channel }}" ]; then
CHANNEL_ARGS="--channel ${{ needs.setup.outputs.channel }}"
fi
~/.cargo/bin/esp-devtool documentation --packages=${{ matrix.packages.name }} --base-url ${{ needs.setup.outputs.base_url }} $CHANNEL_ARGS
# https://github.com/actions/deploy-pages/issues/303#issuecomment-1951207879
- name: Remove problematic '.lock' files
run: find docs -name ".lock" -exec rm -f {} \;
- name: Upload docs for ${{ matrix.packages.name }}
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.packages.name }}
path: "docs/${{ matrix.packages.name }}"
assemble:
needs: [setup, build]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'release:docs')) }}
steps:
# Check out the sources, the xtask reads package versions from the Cargo.toml files
- uses: actions/checkout@v6
- name: Download all docs and xtask
uses: actions/download-artifact@v4
with:
path: "docs/"
# Create an index for _all_ packages. Per-package workflows don't upload the landing page.
- name: Create index.html
run: |
chmod +x docs/xtask/esp-devtool
docs/xtask/esp-devtool documentation-index --base-url ${{ needs.setup.outputs.base_url }}
rm -rf docs/xtask
- if: ${{ github.event.inputs.server == 'preview' || github.event_name == 'pull_request' }}
name: Deploy to preview server
uses: appleboy/scp-action@v0.1.7
with:
host: preview-docs.espressif.com
username: ${{ secrets.PREVIEW_USERNAME }}
key: ${{ secrets.PREVIEW_KEY }}
target: ${{ secrets.PREVIEW_TARGET }}
source: "docs/"
strip_components: 1 # remove the docs prefix
overwrite: true
# Deploying to production server is allowed for manual production runs and for pushes to main
- if: ${{ (github.event.inputs.server == 'production' && github.event_name == 'workflow_dispatch') || github.event_name == 'push' }}
name: Deploy to production server
uses: appleboy/scp-action@v0.1.7
with:
host: docs.espressif.com
username: ${{ secrets.PRODUCTION_USERNAME }}
key: ${{ secrets.PRODUCTION_KEY }}
target: ${{ secrets.PRODUCTION_TARGET }}
source: "docs/"
strip_components: 1 # remove the docs prefix
overwrite: true
docsrs:
runs-on: ubuntu-latest
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'release:docs')) }}
steps:
- uses: actions/checkout@v6
with:
repository: esp-rs/esp-hal
- uses: ./.github/actions/setup-nightly
with:
targets: riscv32imac-unknown-none-elf
components: ""
alias: "true"
- name: Install cargo-docs-rs
run: cargo install cargo-docs-rs --locked
- name: Run cargo-docs-rs
run: cd esp-hal && cargo docs-rs