-
Notifications
You must be signed in to change notification settings - Fork 3
140 lines (132 loc) · 4.17 KB
/
deploy.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
name: Deploy
on:
push:
branches:
- main
tags:
- 'v*.*.*'
env:
# Update the language picker in index.hbs to link new languages.
LANGUAGES: ja
jobs:
book:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# We need the full history below.
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'
- name: Install mdbook-i18n-helpers
run: |
cargo install mdbook-i18n-helpers --locked --version 0.3.0
- name: Build mdbook plugin
run: cargo install --git https://github.com/veryl-lang/veryl mdbook-veryl
- name: Replace wasm path for nightly
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
run: |
sed -i 's/playground\/pkg\/veryl_wasm.js/nightly\/playground\/pkg\/veryl_wasm.js/g' book/theme/index.hbs
- name: Build mdbook
run: mdbook build
working-directory: book
- name: Build all translations
working-directory: book
run: |
for po_lang in ${{ env.LANGUAGES }}; do
POT_CREATION_DATE=$(grep --max-count 1 '^"POT-Creation-Date:' po/$po_lang.po | sed -E 's/".*: (.*)\\n"/\1/')
if [[ $POT_CREATION_DATE == "" ]]; then
POT_CREATION_DATE=now
fi
echo "::group::Building $po_lang translation as of $POT_CREATION_DATE"
rm -r src/
git restore --source "$(git rev-list -n 1 --before "$POT_CREATION_DATE" @)" src/
# Set language and adjust site URL. Clear the redirects
# since they are in sync with the source files, not the
# translation.
MDBOOK_BOOK__LANGUAGE=$po_lang \
MDBOOK_OUTPUT__HTML__SITE_URL=/veryl/book/$po_lang/ \
MDBOOK_OUTPUT__HTML__REDIRECT='{}' \
mdbook build -d book/$po_lang
echo "::endgroup::"
done
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: book
path: book/book/
playground:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- uses: jetli/[email protected]
- name: Build wasm
run: wasm-pack build --target web -d html/pkg --no-typescript
working-directory: playground
- name: Remove .gitignore
run: rm html/pkg/.gitignore
working-directory: playground
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: playground
path: playground/html/
deploy:
if: startsWith(github.ref, 'refs/tags/v')
needs: [book, playground]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download book
uses: actions/download-artifact@v4
with:
name: book
path: public/book
- name: Download playground
uses: actions/download-artifact@v4
with:
name: playground
path: public/playground
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
cname: doc.veryl-lang.org
deploy-nightly:
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
needs: [book, playground]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download book
uses: actions/download-artifact@v4
with:
name: book
path: public/book
- name: Download playground
uses: actions/download-artifact@v4
with:
name: playground
path: public/playground
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
cname: doc.veryl-lang.org
destination_dir: nightly