diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fe0ac23095e3..8c85762d65c4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,32 +3,78 @@ name: Publish # See also TRANSLATIONS.md. on: + pull_request: push: branches: - main workflow_dispatch: -permissions: - contents: read - pages: write - id-token: write - -# Allow one concurrent deployment -concurrency: - group: pages - cancel-in-progress: true - env: CARGO_TERM_COLOR: always # Update the language picker in index.hbs to link new languages. - 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 jobs: - publish: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} + compile-build-tools: runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Update Rust + run: rustup update + + - name: Setup Rust cache + uses: ./.github/workflows/setup-rust-cache + + - name: Install build tools + uses: taiki-e/install-action@v2 + with: + # testing without version first but should be + # mdbook@0.4.48 + # mdbook-svgbob@0.2.2 + # mdbook-pandoc@0.10.4 + # mdbook-i18n-helpers@0.3.6 + # i18n-report@0.2.0 + # mdbook-linkcheck2@0.9.1 + tool: mdbook,mdbook-svgbob,mdbook-pandoc,mdbook-i18n-helpers,i18n-report,mdbook-linkcheck2 + + - name: Install mdbook + run: cargo xtask install-tools + + - name: Upload pre-built-tools for the next tasks + uses: actions/upload-artifact@v4 + with: + name: pre-built-tools + path: /home/runner/.cargo/bin/ + + create-translation: + strategy: + matrix: + 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" + runs-on: ubuntu-latest + needs: compile-build-tools steps: - name: Checkout uses: actions/checkout@v4 @@ -46,18 +92,70 @@ jobs: sudo apt update sudo apt install gettext - - name: Install mdbook - uses: ./.github/workflows/install-mdbook + - name: Download pre-built tools + uses: actions/download-artifact@v4 + with: + name: pre-built-tools + path: /home/runner/.cargo/bin/ + + - name: Make all downloaded tools executable + run: chmod +x /home/runner/.cargo/bin/* + + - name: Install dependencies for mdbook-pandoc + run: | + sudo apt-get update + sudo apt-get install -y texlive texlive-luatex texlive-lang-cjk texlive-lang-arabic librsvg2-bin fonts-noto + curl -LsSf https://github.com/jgm/pandoc/releases/download/3.7.0.1/pandoc-3.7.0.1-linux-amd64.tar.gz | tar zxf - + echo "$PWD/pandoc-3.7.0.1/bin" >> $GITHUB_PATH + shell: bash - name: Build course in English + if: matrix.language == 'en' run: .github/workflows/build.sh en book - - name: Build all translations + - name: Build ${{ matrix.language }} translation + if: matrix.language != 'en' run: | - for po_lang in ${{ env.LANGUAGES }}; do - .github/workflows/build.sh $po_lang book/$po_lang - mv book/$po_lang/html book/html/$po_lang - done + .github/workflows/build.sh ${{ matrix.language }} book/${{ matrix.language }} + mkdir book/html + mv book/${{ matrix.language }}/html book/html/${{ matrix.language }} + + - name: Upload translation + uses: actions/upload-artifact@v4 + with: + name: comprehensive-rust-${{ matrix.language }} + path: book/ + + publish: + runs-on: ubuntu-latest + needs: create-translation + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Update Rust + run: rustup update + + - name: Download pre-built tools + uses: actions/download-artifact@v4 + with: + path: /home/runner/.cargo/bin/ + name: pre-built-tools + + - name: Make all downloaded tools executable + run: chmod +x /home/runner/.cargo/bin/* + + - name: Install Gettext + run: | + sudo apt update + sudo apt install gettext + + - name: Download all translations + uses: actions/download-artifact@v4 + with: + path: book/ + pattern: comprehensive-rust-* + merge-multiple: true - name: Build translation report run: i18n-report report book/html/translation-report.html po/*.po @@ -69,14 +167,8 @@ jobs: for file in synced-po/*.po; do msgmerge --update $file synced-po/messages.pot ; done i18n-report report book/html/synced-translation-report.html synced-po/*.po - - name: Setup Pages - uses: actions/configure-pages@v5 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + - name: Upload all translations (for verification) + uses: actions/upload-artifact@v4 with: - path: book/html - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + name: comprehensive-rust-all + path: book/