Skip to content

Commit 953396d

Browse files
committed
initial refactoring commit
0 parents  commit 953396d

File tree

745 files changed

+1050698
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

745 files changed

+1050698
-0
lines changed

.github/workflows/build.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: build
2+
on:
3+
push:
4+
branches: [ main, develop, gh-build, fresh ]
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
# runs on weblate commit
11+
weblate-commit-build:
12+
if: ${{ contains(github.event.head_commit.message, 'Translated using Weblate') }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: TODO - start full build (delayed)
16+
run: echo "TODO - start delayed full build, maybe 15mins?"
17+
18+
# on regular commit (auto excludes self-commited pot/po files)
19+
full-build:
20+
if: ${{ ! contains(github.event.head_commit.message, 'Translated using Weblate') }}
21+
concurrency:
22+
group: ${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
runs-on: ubuntu-latest
26+
container:
27+
image: sphinxdoc/sphinx
28+
#options: --user 1001 (only if we don't need apt-get)
29+
30+
env:
31+
MAIN_LANGS: en
32+
OTHER_LANGS: de es fr ru nl it ja el bg da et fi lv lt pl pt ro sv sk sl cs hu zh_CN
33+
34+
steps:
35+
- name: Install git
36+
run: |
37+
apt-get -y update
38+
apt-get -y install git ssh curl
39+
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: additional python packages
44+
run: pip3 install -r requirements.txt
45+
46+
- name: quick build docs
47+
run: |
48+
mkdir -p dist/en
49+
mkdir -p build/en/doctrees
50+
sphinx-build -j auto -b html -D language=en -d build/en/doctrees source dist/en
51+
rm -rf dist/en/_sources
52+
53+
- name: upload quick build artifact
54+
id: upload-quick
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: generated documentation (en)
58+
path: dist
59+
60+
- name: trigger docs server to download artifact
61+
uses: appleboy/[email protected]
62+
with:
63+
host: ${{ secrets.DOCS_HOST }}
64+
username: docs
65+
port: ${{ secrets.DOCS_PORT }}
66+
key: ${{ secrets.DEPLOY_AUTH_KEY }}
67+
script: /var/www/docs/deploy/github-trigger.sh en ${{ steps.upload-quick.outputs.artifact-id }} ${{ secrets.DOWNLOAD_TOKEN }}
68+
69+
- name: build pot files
70+
run: sphinx-build -b gettext source locales/
71+
72+
- name: build po files from pot files
73+
shell: bash
74+
run: |
75+
lang=($OTHER_LANGS)
76+
sphinx-intl update -p locales/ ${lang[@]/*/'-l '&' '}
77+
78+
- name: prepare commit into self
79+
run: |
80+
cp -r locales locales.full
81+
rm -rf locales/.doctrees
82+
83+
# this one looks like a upstream bug for the auto-translation
84+
# we will replace all backslashes '\\' with '/bs/' and revert
85+
# this operation before actually building the language
86+
# let's hope this works
87+
- name: WORKAROUND - replace double backslashes in .po files
88+
shell: bash
89+
run: |
90+
sed -ie 's@\\\\@/bs/@g' $(find locales -name "*.po" | xargs)
91+
92+
- name: commit `locales` into repository (on changes)
93+
shell: bash
94+
run: |
95+
# not needed if run on --user 1001
96+
git config --global --add safe.directory $(pwd)
97+
git config --global user.name "GitHub Action"
98+
git config --global user.email "[email protected]"
99+
if (git commit -m "Automated locales generation" locales); then
100+
git push
101+
fi
102+
103+
- name: put original `locales` back
104+
run: |
105+
rm -rf locales
106+
cp -r locales.full locales
107+
108+
- name: TODO - weblate
109+
shell: bash
110+
run: |
111+
for lang in $OTHER_LANGS
112+
do
113+
bash trigger_weblate.sh ${{ secrets.WEBLATE_API_URL }} $lang ${{ secrets.WEBLATE_TOKEN }}
114+
done
115+
116+
- name: WORKAROUND - revert replace double backslashes in .po files
117+
shell: bash
118+
run: |
119+
sed -ie 's@/bs/@\\\\@g' $(find locales -name "*.po" | xargs)
120+
121+
- name: build full docs
122+
run: |
123+
# one _images is enough
124+
mv dist/en/_images dist
125+
126+
cp -r locales source/locales
127+
for lang in $MAIN_LANGS $OTHER_LANGS
128+
do
129+
mkdir -p dist/$lang
130+
mkdir -p build/$lang/doctrees
131+
sphinx-build -j auto -b html -D language=$lang -d build/$lang/doctrees source dist/$lang
132+
rm -rf dist/$lang/_sources dist/$lang/_images
133+
done
134+
135+
- name: upload full build artifact
136+
id: upload-full
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: generated documentation (all)
140+
path: dist
141+
142+
- name: trigger docs server to download (FULL) artifact
143+
uses: appleboy/[email protected]
144+
with:
145+
host: ${{ secrets.DOCS_HOST }}
146+
username: docs
147+
port: ${{ secrets.DOCS_PORT }}
148+
key: ${{ secrets.DEPLOY_AUTH_KEY }}
149+
script: /var/www/docs/deploy/github-trigger.sh all ${{ steps.upload-full.outputs.artifact-id }} ${{ secrets.DOWNLOAD_TOKEN }}
150+
151+
152+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
dist
3+
venv

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
4+
all: venv
5+
venv/bin/sphinx-build -j auto -b html -D language=en -d build/en/doctrees source dist/en
6+
7+
8+
venv:
9+
python -m venv venv
10+
venv/bin/pip3 install -r requirements.txt
11+

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Nitrokey Documentation
2+
3+
4+
5+
### Local build
6+
7+
Be sure to have a recent python installed, then:
8+
9+
```
10+
make
11+
```
12+
13+
The (english) result is to be found in `dist/en`, to show run:
14+
```
15+
firefox dist/en/index.html
16+
```

0 commit comments

Comments
 (0)