-
Notifications
You must be signed in to change notification settings - Fork 249
197 lines (159 loc) · 5.21 KB
/
pages.yaml
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
name: Generate docs
on:
pull_request:
branches:
- main
paths:
- '.github/**'
- 'docs/**'
push:
branches:
- main
env:
BAZELISK_VERSION: 1.23.0
MDBOOK_VERSION: 0.4.42
GH_REPO: ${{ github.repository }}
MIN_VERSION: ${{ github.event.inputs.MIN_VERSION || '0.1.0' }}
FILTER_VERSION: ${{ github.event.inputs.FILTER_VERSION || '' }}
RELEASE_TAG_REGEX: ^\d+\.\d+\.\d+$
jobs:
setup:
runs-on: ubuntu-latest
defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}
steps:
- name: get release tags that match $release_tag_regex
id: get_release_tags
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASES_JSON="$(
curl -s --fail-with-body \
-H "Authorization: token $GH_TOKEN" \
"https://api.github.com/repos/$GH_REPO/tags"
)"
RELEASES_JSON_FILTERED="$(echo "$RELEASES_JSON" |
jq -c \
--arg RELEASE_TAG_REGEX "$RELEASE_TAG_REGEX" \
--arg FILTER_VERSION "$FILTER_VERSION" \
--arg MIN_VERSION "$MIN_VERSION" '
[ "main" ] +
([.[].name |
select(
(test($RELEASE_TAG_REGEX) and
(. | split(".") | map(tonumber) >= ($MIN_VERSION | split(".") | map(tonumber)))
) and ($FILTER_VERSION == "" or . == $FILTER_VERSION)
)
])
'
)"
echo "releases=$RELEASES_JSON_FILTERED"
echo "releases=$RELEASES_JSON_FILTERED" >> "$GITHUB_OUTPUT"
outputs:
releases: ${{ steps.get_release_tags.outputs.releases || '[]' }}
build:
runs-on: ubuntu-latest
needs: setup
defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}
strategy:
fail-fast: false
matrix:
ref: ${{ fromJson(needs.setup.outputs.releases) }}
env:
WORKSPACE: ${{ github.workspace }}
BIN: ${{ github.workspace }}/bin
steps:
- name: Checkout $REF
uses: actions/checkout@v4
with:
ref: ${{ matrix.ref }}
- name: Patch $REF
env:
REF: ${{ matrix.ref }}
run: |
[[ "$REF" == "main" ]] && exit
PATCH=".github/docs-${REF}.patch"
URL="https://raw.githubusercontent.com/$GH_REPO/main/$PATCH"
echo "$URL"
curl -LO --fail-with-body "$URL" || {
echo "No patch found for $REF, exiting..."
exit 0
}
echo "Patching ref: $REF"
git apply "$(basename "$PATCH")"
- name: Install bazelisk
run: |
BAZELISK="bazelisk-linux-amd64"
URL="https://github.com/bazelbuild/bazelisk/releases/download/v$BAZELISK_VERSION/$BAZELISK"
echo "URL=$URL"
curl -LO --fail-with-body "$URL"
chmod +x "$BAZELISK"
mkdir -p "$BIN"
mv "$BAZELISK" "$BIN/bazel"
- name: Install mdbook
run: |
MDBOOK="mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz"
URL="https://github.com/rust-lang/mdBook/releases/download/v$MDBOOK_VERSION/$MDBOOK"
echo "URL=$URL"
curl -LO --fail-with-body "$URL"
tar -xvf "$MDBOOK"
chmod +x mdbook
mkdir -p "$BIN"
mv mdbook "$BIN/mdbook"
- name: bazel run //:generate_docs
run: |
"$BIN/bazel" run //:generate_docs
working-directory: ${{ github.workspace }}/docs
- name: mdbook build root
run: |
"$BIN/mdbook" build
working-directory: ${{ github.workspace }}/docs/root
if: ${{ matrix.ref == 'main' }}
- name: mdbook build docs
run: |
"$BIN/mdbook" build
working-directory: ${{ github.workspace }}/docs
- name: Upload docs root
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.ref }}-root
path: ${{ github.workspace }}/docs/root/book
if-no-files-found: error
if: ${{ github.event_name != 'pull_request' && matrix.ref == 'main' }}
- name: Upload docs/book
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.ref }}
path: ${{ github.workspace }}/docs/book
if-no-files-found: error
if: ${{ github.event_name != 'pull_request' }}
deploy:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name != 'pull_request' }}
defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}
env:
WORKSPACE: ${{ github.workspace }}
steps:
- name: Fetch artifacts (first root)
uses: actions/download-artifact@v4
with:
name: main-root
path: ${{ github.workspace }}/docs/book
- name: Fetch artifacts (then others)
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/docs/pages
- name: Install pages
run: mv "$WORKSPACE/docs/pages/"* "$WORKSPACE/docs/book/"
- name: publish
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: docs
publish_dir: ./docs/book