Skip to content

workflows: add PyPI sdist source mode #21

workflows: add PyPI sdist source mode

workflows: add PyPI sdist source mode #21

Workflow file for this run

# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# Based on the `sdist`/`wheels` jobs of
# https://github.com/leptris/teptris-py/blob/v0.3.20.0/.github/workflows/cibuildwheel.yml
name: Build teptris wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/teptris.yaml not released yet'
required: false
default: ''
cancel-in-progress:
description: Cancel an in-progress run in the same concurrency group.
required: false
type: boolean
default: true
pull_request:
branches: [main]
paths:
- '.github/workflows/build-teptris.yml'
- 'docs/packages/teptris.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-teptris.yml'
- 'docs/packages/teptris.yaml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ case(github.event_name == 'pull_request', true, github.event_name == 'workflow_dispatch', inputs['cancel-in-progress'], false) }}
permissions:
contents: read # to fetch code (actions/checkout)
env:
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
MUSLLINUX_RISCV64_IMAGE: quay.io/pypa/musllinux_1_2_riscv64
jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: teptris
version: ${{ inputs.version }}
build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build teptris ${{ matrix.version }} ${{ matrix.python }}-${{ matrix.platform }}_riscv64
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.setup.outputs.matrix) }}
uses: $/.github/workflows/_build-cibuildwheel.yml
with:
package: teptris
version: ${{ matrix.version }}
# The PyPI sdist contains the vendored libteptris sources and licence.
source: pypi-sdist
patches: true
post-build: |-
python3 - $GITHUB_WORKSPACE/wheelhouse/*.whl <<'EOF'
import sys, zipfile
for whl in sys.argv[1:]:
names = zipfile.ZipFile(whl).namelist()
assert any(n.startswith("teptris/_native") and n.endswith(".so") for n in names), names
assert "teptris/_engine/LICENSE.md" in names, names
sources = [n for n in names if n.startswith("teptris/_engine/src/teptris/") and n.endswith(".c")]
assert len(sources) >= 20, (whl, len(sources))
licenses = {n.rsplit("/", 1)[1] for n in names if ".dist-info/licenses/" in n} - {""}
assert licenses == {"LICENSE.txt"}, (whl, licenses)
print(whl, "ok")
EOF
artifact-tag: ${{ matrix.python }}-${{ matrix.platform }}_riscv64
timeout-minutes: 90
cibw-build: ${{ matrix.python }}-${{ matrix.platform }}_riscv64
cibw-musllinux-riscv64-image: quay.io/pypa/musllinux_1_2_riscv64
# The vendored engine compiles straight into the extension (no
# archive, no PGO - that half of setup.py is only for upstream's
# own release wheels); still stage it under _engine/ so the
# package-data globs in pyproject.toml carry its MIT licence and
# sources into the wheel, same as upstream's own wheels do.
cibw-before-build: >
mkdir -p src/teptris/_engine &&
cp -r vendor/libteptris/src src/teptris/_engine/src &&
cp vendor/libteptris/LICENSE.md src/teptris/_engine/LICENSE.md
cibw-test-sources: tests
cibw-test-command: python -m unittest discover -s tests -v
publish:
name: Publish teptris ${{ matrix.version }}
needs: [setup, build_wheels]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
secrets:
app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
with:
matrix: ${{ needs.setup.outputs.matrix }}
artifact-pattern: teptris-${{ matrix.version }}-*riscv64