The animation engine for agents: blazingly fast math and 3D videos with Manim's Python API, on a Rust GPU core.
Python
Gate release publication on portable builds and artifact validation
Sina Atalaydd42750f4a7c
diff --git a/.github/workflows/create-executables.yaml b/.github/workflows/create-executables.yamlindex bf219c91..e1ef5b3d 100644--- a/.github/workflows/create-executables.yaml+++ b/.github/workflows/create-executables.yaml@@ -26,8 +26,13 @@ jobs:fail-fast: falsematrix:include:- - { platform: linux-x86_64, runner: ubuntu-24.04 }- - { platform: linux-arm64, runner: ubuntu-24.04-arm }+ # The same glibc 2.28 SDKs as cibuildwheel 4.2.1; the launcher is native too.+ - platform: linux-x86_64+ runner: ubuntu-24.04+ sdk: quay.io/pypa/manylinux_2_28_x86_64@sha256:53390351aeb4688114b02c36a23b3e6ce1166ee9b7afc5df1a4f776354fc764c+ - platform: linux-arm64+ runner: ubuntu-24.04-arm+ sdk: quay.io/pypa/manylinux_2_28_aarch64@sha256:ad74e53b713f3b07d8c889c526dc0c6500da9827b45e38739570875fef52e28f- { platform: macos-arm64, runner: macos-26 }- { platform: windows-x86_64, runner: windows-2025 }runs-on: ${{ matrix.runner }}@@ -50,17 +55,37 @@ jobs:name: wheel-${{ matrix.platform }}path: dist- # the executable renders a scene before it is kept: Linux draws it with Mesa's lavapipe- # (macOS has Metal, Windows WARP)- - name: Install a GPU driver+ # Both the launcher and its Python packages must obey the wheel's Linux ABI floor.+ - name: Create the Linux executable in its SDKif: runner.os == 'Linux'run: |- sudo apt-get update- sudo apt-get install --yes --no-install-recommends libvulkan1 mesa-vulkan-drivers+ docker run --rm -v "$PWD:/project" -w /project \+ -v "$(command -v uv):/usr/local/bin/uv:ro" "$SDK" bash -euxc '+ curl --proto "=https" --tlsv1.2 --silent --show-error --fail https://sh.rustup.rs | sh -s -- -y --profile minimal+ export PATH="$HOME/.cargo/bin:$PATH"+ uv run --no-project scripts/release/create_executable.py+ '+ env:+ SDK: ${{ matrix.sdk }}- name: Create the executable+ if: runner.os != 'Linux'run: just create-executable+ # A fresh glibc 2.28 runtime: no build tools, Python, driver, network, or warm cache.+ - name: Run the Linux executable at its minimum glibc+ if: runner.os == 'Linux'+ run: |+ mkdir dist/executable+ tar -xzf dist/manimgx-linux-*.tar.gz -C dist/executable+ docker run --rm --network none -v "$PWD:/source:ro" \+ debian@sha256:bb3dc79fddbca7e8903248ab916bb775c96ec61014b3d02b4f06043b604726dc sh -euxc '+ if command -v python || command -v python3; then exit 1; fi+ test -z "$(find /lib /usr/lib -iname "*vulkan*" -print -quit)"+ ldd --version | head -1+ /source/dist/executable/manimgx self python /source/scripts/release/smoke_test.py /source/dist/executable/manimgx+ '+- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1with:name: executable-${{ matrix.platform }}@@ -68,3 +93,9 @@ jobs:dist/manimgx-*.tar.gzdist/manimgx-*.zipif-no-files-found: error++ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: sources-executable-${{ matrix.platform }}+ path: release-sources/+ if-no-files-found: errordiff --git a/.github/workflows/create-wheels.yaml b/.github/workflows/create-wheels.yamlindex e5978448..d2aadc7b 100644--- a/.github/workflows/create-wheels.yaml+++ b/.github/workflows/create-wheels.yaml@@ -28,6 +28,9 @@ jobs:- { platform: windows-x86_64, runner: windows-2025 }- { platform: pyodide, runner: ubuntu-24.04, archs: wasm32 }runs-on: ${{ matrix.runner }}+ defaults:+ run:+ shell: bashtimeout-minutes: 90permissions:contents: read@@ -53,6 +56,12 @@ jobs:rustup toolchain install 1.93.0 --profile minimal--target wasm32-unknown-emscripten --target wasm32-unknown-unknown+ # cibuildwheel copies /project into its container; its documented /host mount+ # lets the verified source store survive the container, alongside the wheel.+ - name: Retain the Linux builds' sources+ if: runner.os == 'Linux' && matrix.platform != 'pyodide'+ run: echo "MANIMGX_SOURCES=/host${GITHUB_WORKSPACE}/sources" >> "${GITHUB_ENV}"+- name: Build and test the wheelrun: just build-wheel "${PLATFORM}"env:@@ -64,3 +73,11 @@ jobs:name: wheel-${{ matrix.platform }}path: dist/*.whlif-no-files-found: error++ # Source packages are selected in the same image that linked/repaired the wheel.+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ if: runner.os == 'Linux' && matrix.platform != 'pyodide'+ with:+ name: sources-${{ matrix.platform }}+ path: sources/+ if-no-files-found: errordiff --git a/.github/workflows/release.yaml b/.github/workflows/release.yamlindex 452b14fb..6f16c31d 100644--- a/.github/workflows/release.yaml+++ b/.github/workflows/release.yaml@@ -1,13 +1,12 @@# A release: pushing the tag vX.Y.Z (`just release`) builds, tests and publishes manimgx X.Y.Z.-# Everything is built before anything is published. A draft GitHub release gets the wheels, the-# source distribution, the wheels' complete source (the source distribution with every crate-# and each archive the engine is built from, x264's and FFmpeg's among them, whose licenses ask-# for it beside the wheels) and the executables; PyPI gets the wheels (the browser's too), the-# source distribution, and the font packages' versions it doesn't have yet (the fonts change-# rarely, and are released with the manimgx that first requires them); npm gets the package for-# the browser, which installs that PyPI release; ghcr.io gets the Docker image; then the GitHub-# release is published, which makes it immutable. On a pull request that changes how releases-# are made, it builds everything and publishes nothing.+# Every artifact is built and tested before publication. GitHub receives the wheels, source+# distributions, complete source, executables and npm tarball first, so the advertised source+# is public before binaries reach any registry. PyPI receives the fonts before manimgx; npm+# follows PyPI because the browser installs its matching Python release. GHCR receives the+# tested OCI images, with their SBOMs and provenance. Publishing transfers existing artifacts;+# it never rebuilds them. Registry uploads can be retried, and all must succeed to complete.+# GitHub locks release assets and tags only when repository release immutability is enabled;+# this workflow does not change that setting. Pull requests and manual runs publish nothing.name: Release@@ -23,6 +22,8 @@ on:- pyproject.toml- fonts/*/pyproject.toml- browser/**+ - docker/**+ - uv.lock- rust/Cargo.toml- rust/*/Cargo.toml- rust/*/build.rs@@ -95,6 +96,7 @@ jobs:sdist:name: Source distributions+ needs: [wheels, executables]runs-on: ubuntu-24.04timeout-minutes: 60permissions:@@ -110,9 +112,14 @@ jobs:- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0- # the source distribution, and the wheels' complete source made from it: a wheel is built- # from that with Rust and a C compiler alone, the crates read from it, the archives the- # engine's build fetches downloaded into it, so it holds all the wheels are built from+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ pattern: sources-*+ path: release-sources+ merge-multiple: true++ # Native archives and Cargo sources, plus the exact distribution source packages+ # retained by the Linux jobs which linked and repaired the wheels.- name: Build the source distribution and the complete sourcerun: just build-source@@ -135,8 +142,14 @@ jobs:- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1with:- name: fonts- path: dist/manimgx_fonts*+ name: manimgx-fonts+ path: dist/manimgx_fonts-*+ if-no-files-found: error++ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: manimgx-fonts-cjk+ path: dist/manimgx_fonts_cjk-*if-no-files-found: errorexecutables:@@ -146,9 +159,100 @@ jobs:permissions:contents: read- github-release:+ npm-build:+ name: Build the npm artifact+ needs: version+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21+ with:+ tool: just+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0+ with:+ no-cache: true+ - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0+ with:+ node-version: 24+ package-manager-cache: false+ - name: Build, test and pack the browser package+ run: |+ just build-npm+ just test-typescript+ mkdir -p "$RUNNER_TEMP/npm"+ npm pack ./browser --pack-destination "$RUNNER_TEMP/npm"+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: npm+ path: ${{ runner.temp }}/npm/*.tgz+ if-no-files-found: error++ docker-build:+ name: Build and test the ${{ matrix.arch }} image+ needs: [version, wheels, sdist]+ strategy:+ fail-fast: false+ matrix:+ include:+ - { arch: amd64, wheel: x86_64, runner: ubuntu-24.04 }+ - { arch: arm64, wheel: arm64, runner: ubuntu-24.04-arm }+ runs-on: ${{ matrix.runner }}+ timeout-minutes: 30+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ pattern: "{wheel-linux-${{ matrix.wheel }},manimgx-fonts,manimgx-fonts-cjk}"+ path: docker/wheels+ merge-multiple: true+ - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0+ - name: Lock the image's runtime dependencies+ run: >-+ uv export --frozen --package manimgx --no-default-groups --no-emit-workspace+ --no-header --no-annotate > docker/wheels/requirements.txt+ - name: Build the OCI artifact with provenance and an SBOM+ run: |+ docker buildx build --target release --platform "linux/$ARCH" \+ --tag "ghcr.io/$GITHUB_REPOSITORY:$VERSION" \+ --label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \+ --label "org.opencontainers.image.revision=$GITHUB_SHA" \+ --label "org.opencontainers.image.version=$VERSION" \+ --label 'org.opencontainers.image.licenses=MIT AND GPL-3.0-or-later' \+ --provenance=mode=max --sbom=true \+ --output "type=oci,dest=$RUNNER_TEMP/image-$ARCH.tar" docker+ env:+ ARCH: ${{ matrix.arch }}+ VERSION: ${{ needs.version.outputs.version }}+ - name: Test the actual image without network access+ run: |+ sudo apt-get update+ sudo apt-get install --yes --no-install-recommends skopeo+ skopeo copy "oci-archive:$RUNNER_TEMP/image-$ARCH.tar" docker-daemon:manimgx:smoke+ docker run --rm --network none --entrypoint python \+ -v "$PWD/scripts/release/smoke_test.py:/smoke_test.py:ro" \+ manimgx:smoke /smoke_test.py+ env:+ ARCH: ${{ matrix.arch }}+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: docker-${{ matrix.arch }}+ path: ${{ runner.temp }}/image-${{ matrix.arch }}.tar+ if-no-files-found: error++ draft-release:name: Draft the GitHub release- needs: [version, test, wheels, sdist, executables]+ needs: [version, test, wheels, sdist, executables, npm-build, docker-build]if: github.ref_type == 'tag'runs-on: ubuntu-24.04timeout-minutes: 10@@ -169,7 +273,7 @@ jobs:- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1with:- pattern: "{wheel-*,sdist,source,executable-*}"+ pattern: "{wheel-*,sdist,source,executable-*,npm}"path: assetsmerge-multiple: true@@ -189,7 +293,7 @@ jobs:printf '\n---\n\n'echo "The wheels and executables hold FFmpeg, under the LGPL, and all but the" \"browser's wheel hold x264, under the GPL, which makes them, as a whole," \- "GPL-3.0-or-later. Their complete source, which builds them offline, is" \+ "GPL-3.0-or-later. Their complete source and build recipes are" \"[manimgx-${VERSION}-source.tar.xz](${source}): the source of manimgx, of every" \"crate, and of each library the engine is built from. This software uses code of" \"[FFmpeg](https://ffmpeg.org) licensed under the LGPLv2.1 and its source can be" \@@ -204,9 +308,55 @@ jobs:VERSION: ${{ needs.version.outputs.version }}PRERELEASE: ${{ needs.version.outputs.prerelease }}+ github-release:+ name: Publish the artifacts and their source+ needs: draft-release+ runs-on: ubuntu-24.04+ timeout-minutes: 5+ permissions:+ contents: write+ steps:+ - name: Make the complete source available before registry uploads+ run: gh release edit "${GITHUB_REF_NAME}" --draft=false --repo "${GITHUB_REPOSITORY}"+ env:+ GH_TOKEN: ${{ github.token }}++ pypi-fonts:+ name: Publish ${{ matrix.package }} to PyPI+ needs: github-release+ strategy:+ fail-fast: false+ matrix:+ include:+ - { package: manimgx-fonts, environment: pypi-fonts }+ - { package: manimgx-fonts-cjk, environment: pypi-fonts-cjk }+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ # A pending PyPI publisher identifies one project by its workflow and environment.+ # Each font package gets its own identity and only its own distributions.+ environment:+ name: ${{ matrix.environment }}+ url: https://pypi.org/project/${{ matrix.package }}/+ permissions:+ id-token: write # trusted publishing, and the attestations' signatures+ steps:+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ name: ${{ matrix.package }}+ path: dist++ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0++ - uses: astral-sh/attest-action@f589a42a7efb6fe400b4f400de60b4bc90390027 # v0.0.6++ # The fonts change rarely: skip files PyPI already has.+ - name: Publish to PyPI+ run: uv publish --check-url https://pypi.org/simple/+pypi:- name: Publish to PyPI- needs: [version, github-release]+ name: Publish manimgx to PyPI+ # Publish the required fonts first, so manimgx is installable as soon as it appears.+ needs: [version, github-release, pypi-fonts]runs-on: ubuntu-24.04timeout-minutes: 10environment:@@ -217,7 +367,7 @@ jobs:steps:- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1with:- pattern: "{wheel-*,sdist,fonts}"+ pattern: "{wheel-*,sdist}"path: distmerge-multiple: true@@ -226,44 +376,57 @@ jobs:# each file's PEP 740 attestation, which `uv publish` uploads beside it- uses: astral-sh/attest-action@f589a42a7efb6fe400b4f400de60b4bc90390027 # v0.0.6- # a file PyPI has already (a font package's version released before) is skipped+ # A retry skips files already uploaded by an earlier attempt.- name: Publish to PyPIrun: uv publish --check-url https://pypi.org/simple/docker:- name: Publish the Docker image- needs: [version, pypi]- uses: docker/github-builder/.github/workflows/build.yml@58cb9f5b71b1836d6f690c1e95effdeb9b98cb8a # v1.17.0+ name: Publish the tested Docker images+ needs: [version, github-release, docker-build]+ runs-on: ubuntu-24.04+ timeout-minutes: 20permissions:contents: read- id-token: write # the provenance's signature- packages: write # ghcr.io- with:- context: docker- output: image- push: true- platforms: linux/amd64,linux/arm64- build-args: VERSION=${{ needs.version.outputs.version }}- meta-images: ghcr.io/${{ github.repository }}- # the OCI labels and annotations: the image's source, version and description, and its- # licenses, which are not the repository's alone: manimgx's code is MIT, and the engine the- # image installs holds x264, which makes it, as a whole, GPL-3.0-or-later (as the release's- # notes say)- set-meta-labels: true- set-meta-annotations: true- meta-labels: org.opencontainers.image.licenses=MIT AND GPL-3.0-or-later- meta-annotations: org.opencontainers.image.licenses=MIT AND GPL-3.0-or-later- # an SBOM beside the provenance: each package the image holds, with its license (manimgx's- # as its wheel's metadata states it)- sbom: true- meta-tags: |- type=pep440,pattern={{version}}- type=pep440,pattern={{major}}.{{minor}}- secrets:- registry-auths: |- - registry: ghcr.io+ packages: write+ id-token: write+ attestations: write+ artifact-metadata: write+ steps:+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ pattern: docker-*+ path: images+ merge-multiple: true+ - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0+ - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0+ with:+ registry: ghcr.iousername: ${{ github.actor }}password: ${{ secrets.GITHUB_TOKEN }}+ - name: Transfer exact images and assemble their platform index+ id: publish+ run: |+ sudo apt-get update+ sudo apt-get install --yes --no-install-recommends skopeo+ image="ghcr.io/$GITHUB_REPOSITORY"+ for arch in amd64 arm64; do+ skopeo copy --all --preserve-digests --authfile "$HOME/.docker/config.json" \+ "oci-archive:images/image-$arch.tar" "docker://$image:$VERSION-$arch"+ done+ tags=(--tag "$image:$VERSION")+ if [[ "$PRERELEASE" == false ]]; then tags+=(--tag "$image:${VERSION%.*}"); fi+ docker buildx imagetools create "${tags[@]}" "$image:$VERSION-amd64" "$image:$VERSION-arm64"+ skopeo inspect --raw "docker://$image:$VERSION" > index.json+ jq -e '[.manifests[].platform | select(.os == "linux") | .architecture] | sort == ["amd64", "arm64"]' index.json+ echo "digest=sha256:$(sha256sum index.json | cut -d ' ' -f 1)" >> "$GITHUB_OUTPUT"+ env:+ VERSION: ${{ needs.version.outputs.version }}+ PRERELEASE: ${{ needs.version.outputs.prerelease }}+ - uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2+ with:+ subject-name: ghcr.io/${{ github.repository }}+ subject-digest: ${{ steps.publish.outputs.digest }}+ push-to-registry: truenpm:name: Publish to npm@@ -281,41 +444,34 @@ jobs:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:persist-credentials: false-- - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21- with:- tool: just-- - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0-- # what is published is built from nothing cached- - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0+ sparse-checkout: scripts/release+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1with:- no-cache: true-+ name: npm+ path: dist# trusted publishing needs npm 11.5.1 or later- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0with:node-version: 24registry-url: https://registry.npmjs.orgpackage-manager-cache: false-- - name: Build the package- run: just build-npm-- - name: Publish to npm- run: npm publish --provenance --access public- working-directory: browser+ - name: Publish and verify the exact built tarball+ run: python3 scripts/release/publish_npm.py dist/*.tgz+ env:+ # Only needed for the first release, before npm allows a trusted publisher.+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}publish:- name: Publish the GitHub release+ name: Verify release completionneeds: [pypi, npm, docker]runs-on: ubuntu-24.04timeout-minutes: 5permissions:- contents: write+ contents: readsteps:- - name: Publish the release- run: gh release edit "${GITHUB_REF_NAME}" --draft=false --repo "${GITHUB_REPOSITORY}"+ - name: Confirm the public release after every registry succeeded+ run: |+ gh release view "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" --json isDraft,url \+ --jq 'if .isDraft then error("release is still a draft") else .url end' >> "$GITHUB_STEP_SUMMARY"env:GH_TOKEN: ${{ github.token }}diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yamlindex 6c33cab5..21293adf 100644--- a/.github/workflows/test.yaml+++ b/.github/workflows/test.yaml@@ -1,7 +1,7 @@# The checks every change must pass: the pre-commit checks, and the tests on each OS and Python# manimgx supports. Their coverage is combined into one report on Cloudflare: main's at# https://coverage.manimgx.academa.ai, a pull request's on its preview URL, and each commit's-# linked from its "coverage" status. The release runs this workflow before it builds anything.+# linked from its "coverage" status. A tagged release requires these checks before publication.name: Test@@ -16,8 +16,8 @@ permissions: {}concurrency:group: test-${{ github.event.pull_request.number || github.ref }}- # a newer commit supersedes a pull request's run; main's runs all finish- cancel-in-progress: ${{ github.event_name == 'pull_request' }}+ # a newer branch experiment supersedes its predecessor; main's active run finishes+ cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}env:WRANGLER_VERSION: "4.141.0"@@ -40,17 +40,14 @@ jobs:- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0- # the engine's dependencies, compiled; only main's runs save them, for everyone's runs- - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2- with:- workspaces: rust- shared-key: engine- save-if: ${{ github.ref == 'refs/heads/main' }}-- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0- name: Run pre-commit checks- run: just check+ run: |+ uv sync --frozen --no-install-project+ just check+ env:+ UV_NO_SYNC: "1"typescript:name: Test the browser package@@ -65,15 +62,85 @@ jobs:- uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21with:- tool: just+ tool: just,[email protected]- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0+ - name: Install the browser engine target+ run: rustup target add wasm32-unknown-unknown++ - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2+ with:+ workspaces: rust+ shared-key: web-player+ save-if: ${{ github.event_name != 'pull_request' }}++ - name: Check the browser engine+ run: just check-rust-web++ - name: Test browser audio ownership+ run: CHROMEDRIVER="$CHROMEWEBDRIVER/chromedriver" just test-rust-web+- name: Test the browser packagerun: just test-typescript+ wheel:+ name: Build and link on ${{ matrix.os }}+ strategy:+ fail-fast: false+ matrix:+ os: [ubuntu-24.04, macos-26, windows-2025]+ runs-on: ${{ matrix.os }}+ timeout-minutes: 60+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false++ - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21+ with:+ tool: just++ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0+ with:+ python-version: "3.13"++ - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2+ with:+ workspaces: rust+ shared-key: engine+ save-if: ${{ github.event_name != 'pull_request' }}++ - name: Test source acquisition and linked codecs+ run: cargo test --locked --release --manifest-path rust/Cargo.toml -p fetch -p ffmpeg++ # The abi3 wheel is the same artifact on both supported Python versions.+ - name: Build the wheel+ run: uv build --wheel --python 3.13 --out-dir dist++ # The native tests exercise the renderer too, before the wheel is accepted.+ - name: Install a GPU driver+ if: runner.os == 'Linux'+ run: |+ sudo apt-get update+ sudo apt-get install --yes --no-install-recommends libvulkan1 mesa-vulkan-drivers++ - name: Test the Rust core+ run: just test-rust++ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: wheel-${{ matrix.os }}+ path: dist/*.whl+ if-no-files-found: error+ retention-days: 7+test:name: Test with Python ${{ matrix.python-version }} on ${{ matrix.os }}+ needs: wheel+ if: ${{ !cancelled() }}strategy:fail-fast: falsematrix:@@ -83,9 +150,13 @@ jobs:timeout-minutes: 120permissions:contents: read+ defaults:+ run:+ shell: bashenv:# the job's coverage data, named after the job (its subprocesses add suffixes)COVERAGE_FILE: ${{ github.workspace }}/.coverage.${{ matrix.os }}-python${{ matrix.python-version }}+ UV_NO_SYNC: "1"steps:- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1with:@@ -107,21 +178,42 @@ jobs:with:python-version: ${{ matrix.python-version }}- - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1with:- workspaces: rust- shared-key: engine- save-if: ${{ github.ref == 'refs/heads/main' }}+ name: wheel-${{ matrix.os }}+ path: dist++ - name: Install the wheel and test dependencies+ run: |+ uv sync --frozen --no-install-project+ uv pip install --no-deps dist/*.whl++ - name: Check the installed product+ id: runtime+ run: uv run --frozen --no-sync python -m scripts.release.smoke_test++ - name: Acquire the verified corpus baseline+ run: uv run --frozen --no-sync python -m tests.integration.corpus baseline acquire- name: Test+ if: ${{ !cancelled() && steps.runtime.outcome == 'success' }}run: just test-coverage- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ if: ${{ !cancelled() }}with:name: coverage-${{ matrix.os }}-python${{ matrix.python-version }}path: .coverage.*include-hidden-files: true- if-no-files-found: error+ if-no-files-found: warn+ retention-days: 7++ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ if: ${{ !cancelled() }}+ with:+ name: rendering-${{ matrix.os }}-python${{ matrix.python-version }}+ path: tests/integration/_diffs/+ if-no-files-found: ignoreretention-days: 7coverage:@@ -155,24 +247,37 @@ jobs:- name: Combine the coverageid: combine+ if: ${{ hashFiles('coverage/.coverage.*') != '' }}run: |+ uv sync --frozen --no-install-projectjust combine-coverage coverage >> "$GITHUB_STEP_SUMMARY"- total="$(uvx coverage report --format=total --precision=1)"+ total="$(uv run --frozen --no-sync coverage report --format=total --precision=1)"+ if [[ "${TEST_RESULT}" != success ]]; then+ echo "Partial coverage: one or more test jobs did not finish successfully." >> "$GITHUB_STEP_SUMMARY"+ total="partial"+ fi# the README's badge: https://shields.io/badges/endpoint-badgejq --null-input --arg total "$total" '{- schemaVersion: 1, label: "coverage", message: "\($total)%",- color: (($total | tonumber) as $t | if $t >= 90 then "brightgreen"- elif $t >= 75 then "yellow" else "red" end)+ schemaVersion: 1, label: "coverage",+ message: (if $total == "partial" then $total else "\($total)%" end),+ color: (if $total == "partial" then "lightgrey" else+ (($total | tonumber) as $t | if $t >= 90 then "brightgreen"+ elif $t >= 75 then "yellow" else "red" end) end)}' > htmlcov/badge.jsonecho "total=${total}" >> "$GITHUB_OUTPUT"+ env:+ TEST_RESULT: ${{ needs.test.result }}+ UV_NO_SYNC: "1"++ - name: Report unavailable coverage+ if: ${{ hashFiles('coverage/.coverage.*') == '' }}+ run: echo "Coverage unavailable because no test job produced data." >> "$GITHUB_STEP_SUMMARY"- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ if: steps.combine.outcome == 'success'with:name: coverage-report- path: |- htmlcov/- .github/deploy/coverage.jsonc- # the deployment config lives in .github/, a hidden directory+ path: htmlcov/include-hidden-files: trueif-no-files-found: errorretention-days: 7@@ -183,21 +288,31 @@ jobs:# main's pushes, and pull requests from this repository: pull requests from forks and from# Dependabot get no secretsif: >-+ needs.coverage.outputs.total != '' && needs.coverage.outputs.total != 'partial' && ((github.event_name == 'push' && github.ref == 'refs/heads/main')|| (github.event_name == 'pull_request'&& github.event.pull_request.head.repo.full_name == github.repository- && github.actor != 'dependabot[bot]')+ && github.actor != 'dependabot[bot]'))runs-on: ubuntu-24.04timeout-minutes: 10permissions:+ contents: readstatuses: writeenvironment:name: ${{ github.event_name == 'push' && 'coverage' || 'coverage-preview' }}url: ${{ steps.publish.outputs.url }}steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ ref: ${{ github.event.pull_request.base.sha || github.sha }}+ persist-credentials: false+ sparse-checkout: .github/deploy+ sparse-checkout-cone-mode: false+- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1with:name: coverage-report+ path: htmlcov- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0@@ -224,7 +339,7 @@ jobs:--field target_url="${deployment}"env:CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}- CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}+ CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}WRANGLER_OUTPUT_FILE_PATH: ${{ runner.temp }}/wrangler.ndjsonGH_TOKEN: ${{ github.token }}SHA: ${{ github.event.pull_request.head.sha || github.sha }}diff --git a/scripts/release/publish_npm.py b/scripts/release/publish_npm.pynew file mode 100644index 00000000..b13d8b7b--- /dev/null+++ b/scripts/release/publish_npm.py@@ -0,0 +1,54 @@+"""Publish a built npm tarball, accepting a retry only when the registry has its exact bytes."""++import argparse+import base64+import hashlib+import json+import subprocess+import tarfile+from pathlib import Path+++def publish(archive: Path) -> None:+ with tarfile.open(archive) as package:+ metadata = package.extractfile("package/package.json")+ if metadata is None:+ raise ValueError("npm archive has no package.json")+ manifest = json.load(metadata)+ name = f"{manifest['name']}@{manifest['version']}"+ integrity = "sha512-" + base64.b64encode(+ hashlib.sha512(archive.read_bytes()).digest()+ ).decode("ascii")++ def exists() -> bool:+ result = subprocess.run(+ ["npm", "view", name, "dist.integrity", "--json"],+ capture_output=True,+ text=True,+ check=False,+ )+ record = json.loads(result.stdout)+ if result.returncode:+ if (+ isinstance(record, dict)+ and record.get("error", {}).get("code") == "E404"+ ):+ return False+ raise RuntimeError(f"cannot inspect {name}: {result.stdout}{result.stderr}")+ if record != integrity:+ raise ValueError(f"{name} already exists with different artifact bytes")+ return True++ if not exists():+ subprocess.run(+ ["npm", "publish", str(archive), "--provenance", "--access", "public"],+ check=True,+ )+ if not exists():+ raise RuntimeError(f"{name} was not available after publication")+++if __name__ == "__main__":+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("archive", type=Path)+ publish(parser.parse_args().archive)