|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `linux` job of |
| 5 | +# https://github.com/mgd020/mjml-python/blob/v1.4.1/.github/workflows/_build-wheels.yml |
| 6 | +name: Build mjml-python wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Version glob to (re)build; empty builds every version of docs/packages/mjml-python.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-mjml-python.yml' |
| 19 | + - 'docs/packages/mjml-python.yaml' |
| 20 | + - 'patches/mjml-python/**' |
| 21 | + push: |
| 22 | + branches: [main] |
| 23 | + paths: |
| 24 | + - '.github/workflows/build-mjml-python.yml' |
| 25 | + - 'docs/packages/mjml-python.yaml' |
| 26 | + - 'patches/mjml-python/**' |
| 27 | + |
| 28 | +concurrency: |
| 29 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +permissions: |
| 33 | + contents: read # to fetch code (actions/checkout) |
| 34 | + |
| 35 | +env: |
| 36 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 37 | + |
| 38 | +jobs: |
| 39 | + setup: |
| 40 | + uses: $/.github/workflows/_setup.yml |
| 41 | + with: |
| 42 | + package: mjml-python |
| 43 | + version: ${{ inputs.version }} |
| 44 | + |
| 45 | + build_wheels: |
| 46 | + needs: [setup] |
| 47 | + if: needs.setup.outputs.versions != '[]' |
| 48 | + name: Build mjml-python ${{ matrix.version }} ${{ matrix.tag }}-manylinux_riscv64 |
| 49 | + runs-on: ubuntu-24.04-riscv |
| 50 | + timeout-minutes: 60 |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: |
| 54 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 55 | + include: |
| 56 | + # Cargo.toml hardcodes pyo3's abi3-py38 feature unconditionally; |
| 57 | + # the riscv64 manylinux image's oldest interpreter is cp39 (no |
| 58 | + # cp38), so patches/ bumps it to abi3-py39 -- gotcha 96. Built on |
| 59 | + # cp39 and re-tested on the newer ones via find_compatible_wheel. |
| 60 | + - tag: cp39-abi3 |
| 61 | + build: >- |
| 62 | + cp39-manylinux_riscv64 cp310-manylinux_riscv64 |
| 63 | + cp311-manylinux_riscv64 cp312-manylinux_riscv64 |
| 64 | + cp313-manylinux_riscv64 cp314-manylinux_riscv64 |
| 65 | + - tag: cp314t |
| 66 | + build: cp314t-manylinux_riscv64 |
| 67 | + |
| 68 | + env: |
| 69 | + MJML_PYTHON_VERSION: ${{ matrix.version }} |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Checkout mjml-python v${{ env.MJML_PYTHON_VERSION }} |
| 73 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 74 | + with: |
| 75 | + repository: mgd020/mjml-python |
| 76 | + ref: v${{ env.MJML_PYTHON_VERSION }} |
| 77 | + persist-credentials: false |
| 78 | + |
| 79 | + - name: Checkout python-wheels |
| 80 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 81 | + with: |
| 82 | + path: python-wheels |
| 83 | + persist-credentials: false |
| 84 | + |
| 85 | + - name: Patch mjml-python source |
| 86 | + run: git apply python-wheels/patches/mjml-python/${{ env.MJML_PYTHON_VERSION }}/00*.patch |
| 87 | + |
| 88 | + - name: Build wheels |
| 89 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 90 | + with: |
| 91 | + output-dir: wheelhouse/ |
| 92 | + env: |
| 93 | + # musllinux is dropped: rustup.rs ships no riscv64 musl toolchain. |
| 94 | + CIBW_BUILD: ${{ matrix.build }} |
| 95 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 96 | + # mjml-python ships no [tool.cibuildwheel], so the Rust toolchain |
| 97 | + # its maturin backend needs is installed in-container here. |
| 98 | + CIBW_BEFORE_ALL_LINUX: >- |
| 99 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 100 | + CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin" |
| 101 | + CIBW_TEST_SOURCES: tests |
| 102 | + CIBW_TEST_COMMAND: >- |
| 103 | + python -c "import mjml.mjml as m; assert m.__file__.endswith('.so'), m.__file__" && |
| 104 | + python -m unittest -v |
| 105 | +
|
| 106 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 107 | + with: |
| 108 | + name: mjml-python-${{ env.MJML_PYTHON_VERSION }}-${{ matrix.tag }}-manylinux_riscv64 |
| 109 | + path: wheelhouse/*.whl |
| 110 | + if-no-files-found: error |
| 111 | + |
| 112 | + publish: |
| 113 | + name: Publish mjml-python ${{ matrix.version }} |
| 114 | + needs: [setup, build_wheels] |
| 115 | + if: needs.setup.outputs.versions != '[]' |
| 116 | + strategy: |
| 117 | + fail-fast: false |
| 118 | + matrix: |
| 119 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 120 | + permissions: |
| 121 | + contents: write |
| 122 | + pull-requests: write |
| 123 | + uses: $/.github/workflows/_publish-wheel.yml |
| 124 | + secrets: |
| 125 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 126 | + with: |
| 127 | + artifact-pattern: mjml-python-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments