Skip to content

Commit 0cc11a5

Browse files
ci: Use a job matrix for translations and combine the artifacts in the publish job
1 parent 20307f6 commit 0cc11a5

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

.github/workflows/publish.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ on:
1212
env:
1313
CARGO_TERM_COLOR: always
1414
# Update the language picker in index.hbs to link new languages.
15-
LANGUAGES: ar bn da de el es fa fr id it ja ko pl pt-BR ro ru tr uk vi zh-CN zh-TW
1615

1716
jobs:
18-
publish:
17+
create-translation:
18+
strategy:
19+
matrix:
20+
language: ["en", "ar", "bn", "da", "de", "el", "es", "fa", "fr", "id", "it", "ja", "ko", "pl", "pt-BR", "ro", "ru", "tr", "uk", "vi", "zh-CN", "zh-TW"]
1921
runs-on: ubuntu-latest
2022
steps:
2123
- name: Checkout
@@ -38,14 +40,32 @@ jobs:
3840
uses: ./.github/workflows/install-mdbook
3941

4042
- name: Build course in English
43+
if: matrix.language == 'en'
4144
run: .github/workflows/build.sh en book
4245

43-
- name: Build all translations
46+
- name: Build ${{ matrix.language }} translation
47+
if: matrix.language != 'en'
4448
run: |
45-
for po_lang in ${{ env.LANGUAGES }}; do
46-
.github/workflows/build.sh $po_lang book/$po_lang
47-
mv book/$po_lang/html book/html/$po_lang
48-
done
49+
.github/workflows/build.sh ${{ matrix.language }} book/${{ matrix.language }}
50+
mkdir book/html
51+
mv book/${{ matrix.language }}/html book/html/${{ matrix.language }}
52+
53+
- name: Upload translation
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: comprehensive-rust-${{ matrix.language }}
57+
path: book/
58+
59+
publish:
60+
runs-on: ubuntu-latest
61+
needs: create-translation
62+
steps:
63+
- name: Download all translations
64+
uses: actions/download-artifact@v4
65+
with:
66+
path: book/
67+
pattern: comprehensive-rust-*
68+
merge-multiple: true
4969

5070
- name: Build translation report
5171
run: i18n-report report book/html/translation-report.html po/*.po
@@ -56,3 +76,9 @@ jobs:
5676
MDBOOK_OUTPUT='{"xgettext": {"pot-file": "messages.pot", "granularity": 0}}' mdbook build -d synced-po
5777
for file in synced-po/*.po; do msgmerge --update $file synced-po/messages.pot ; done
5878
i18n-report report book/html/synced-translation-report.html synced-po/*.po
79+
80+
- name: Upload all translations (for verification)
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: comprehensive-rust-all
84+
path: book/

0 commit comments

Comments
 (0)