-
-
Notifications
You must be signed in to change notification settings - Fork 177
148 lines (140 loc) · 6.92 KB
/
docs.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
name: docs
on:
push:
branches: [main]
paths:
- ".github/workflows/docs.yml"
- "gdk4/**"
- "gdk4-macos/**"
- "gdk4-wayland/**"
- "gdk4-win32/**"
- "gdk4-x11/**"
- "gsk4/**"
- "gtk4/**"
- "gtk4-macros/**"
- "**/README.md"
pull_request:
paths:
- ".github/workflows/docs.yml"
- "gdk4/**"
- "gdk4-macos/**"
- "gdk4-wayland/**"
- "gdk4-win32/**"
- "gdk4-x11/**"
- "gsk4/**"
- "gtk4/**"
- "gtk4-macros/**"
- "**/README.md"
workflow_dispatch:
release:
types: [published]
jobs:
build-deploy:
runs-on: ubuntu-latest
name: build
container:
image: ghcr.io/gtk-rs/gtk4-rs/gtk4:latest
env:
RELEASES: |
0.9=0.9
0.8=0.8
0.7=0.7
0.6=0.6
0.5=0.5
0.4=0.4
0.3=0.3
RUSTFLAGS: --cfg docsrs
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
set-safe-directory: true
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- run: git config --global --add safe.directory /__w/gtk4-rs/gtk4-rs
- run: git submodule update --checkout
- run: cargo install rustdoc-stripper
- run: git clone https://gitlab.gnome.org/World/Rust/gir-rustdoc/ # checkout action doesn't support random urls
- run: python3 ./generator.py --embed-docs --yes ./
- run: echo "RELEASE=$(echo '${{ github.event.release.tag_name }}' | grep -Po '(\d+)\.(\d+)')" >> ${GITHUB_ENV}
- run: echo "DEST=$(if [ "$GITHUB_EVENT_NAME" == "release" ]; then echo 'stable/${{ env.RELEASE }}'; else echo 'git'; fi)" >> ${GITHUB_ENV}
- run: echo "RUSTDOCFLAGS=$(eval python3 ./gir-rustdoc/gir-rustdoc.py --pages-url 'https://gtk-rs.org/gtk4-rs/' --default-branch 'main' pre-docs | xargs)" >> ${GITHUB_ENV}
env:
RUSTDOCFLAGS: >
--extern-html-root-url=wayland_client=https://smithay.github.io/wayland-rs/
--extern-html-root-url=x11=https://docs.rs/x11/latest/
--extern-html-root-url=khronos_egl=https://docs.rs/khronos-egl/latest/
--extern-html-root-url=xkb=https://docs.rs/xkb/latest/
--extern-html-root-url=windows=https://microsoft.github.io/windows-docs-rs/doc/
--extern-html-root-url=gl=https://docs.rs/gl/latest/
--cfg docsrs
-Zunstable-options --generate-link-to-definition
- uses: actions-rs/cargo@v1
with:
command: doc
args: >
-p gdk4 -p gdk4-sys
-p gdk4-wayland -p gdk4-wayland-sys
-p gdk4-win32 -p gdk4-win32-sys
-p gdk4-x11 -p gdk4-x11-sys
-p gsk4 -p gsk4-sys
-p gtk4 -p gtk4-sys
-p gdk4-macos -p gdk4-macos-sys
-p gtk4-macros
--all-features
--no-deps
- name: Fix broken URLs
run: |
sed -i 's|section-list-widget.html|https://docs.gtk.org/gtk4/section-list-widget.html|g' target/doc/gtk4/struct.ColumnView.html
sed -i 's|section-list-widget.html|https://docs.gtk.org/gtk4/section-list-widget.html|g' target/doc/gtk4/struct.ListBox.html
sed -i 's|section-list-widget.html|https://docs.gtk.org/gtk4/section-list-widget.html|g' target/doc/gtk4/struct.ListView.html
sed -i 's|section-list-widget.html|https://docs.gtk.org/gtk4/section-list-widget.html|g' target/doc/gtk4/struct.GridView.html
sed -i 's|input-handling.html|https://docs.gtk.org/gtk4/input-handling.html|g' target/doc/gtk4/struct.EventController.html
sed -i 's|coordinates.html|https://docs.gtk.org/gtk4/coordinates.html|g' target/doc/gdk4/struct.Event.html
sed -i 's|coordinates.html|https://docs.gtk.org/gtk4/coordinates.html|g' target/doc/gtk4/struct.Widget.html
sed -i 's|section-text-widget.html|https://docs.gtk.org/gtk4/section-text-widget.html|g' target/doc/gtk4/struct.TextBuffer.html
sed -i 's|section-text-widget.html|https://docs.gtk.org/gtk4/section-text-widget.html|g' target/doc/gtk4/struct.TextIter.html
sed -i 's|section-text-widget.html|https://docs.gtk.org/gtk4/section-text-widget.html|g' target/doc/gtk4/struct.TextMark.html
sed -i 's|section-text-widget.html|https://docs.gtk.org/gtk4/section-text-widget.html|g' target/doc/gtk4/struct.TextTag.html
sed -i 's|section-text-widget.html|https://docs.gtk.org/gtk4/section-text-widget.html|g' target/doc/gtk4/struct.TextTagTable.html
sed -i 's|section-text-widget.html|https://docs.gtk.org/gtk4/section-text-widget.html|g' target/doc/gtk4/struct.TextView.html
sed -i 's|section-tree-widget.html|https://docs.gtk.org/gtk4/section-tree-widget.html|g' target/doc/gtk4/struct.TreeView.html
- name: GTK Docs Images
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' }}
run: |
git clone --depth=1 https://gitlab.gnome.org/GNOME/gtk --no-checkout ./gtk-src
cd ./gtk-src
git sparse-checkout init --cone
git sparse-checkout set docs/reference/gtk/images
git checkout main
mv ./docs/reference/gtk/images/*.png ../target/doc/gtk4
- name: Grab gtk-rs LOGO
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' }}
run: |
wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs-16.png -O ./target/doc/favicon-16x16.png
wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs-32.png -O ./target/doc/favicon-32x32.png
wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs-256.png -O ./target/doc/rust-logo.png
wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs.svg -O ./target/doc/rust-logo.svg
wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs.svg -O ./target/doc/favicon.svg
- name: deploy
uses: peaceiris/actions-gh-pages@v4
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc/
keep_files: false
destination_dir: ${{ env.DEST }}/docs
- run: python3 ./gir-rustdoc/gir-rustdoc.py --project-title 'GTK 4 Rust bindings' html-index --early-section 'Book' '<ul><li><a href="stable/latest/book">Latest stable</a></li></ul>'
- name: deploy index page
uses: peaceiris/actions-gh-pages@v4
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public/
keep_files: true
#force_orphan: true
destination_dir: ./