deploy #72
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: [workflow_dispatch] | |
name: deploy | |
jobs: | |
deploy: | |
name: Build and publish to GitHub pages | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: wasm32-unknown-unknown | |
- name: Install protoc compiler | |
run: | | |
sudo apt-get update | |
sudo apt-get install protobuf-compiler | |
- uses: jetli/[email protected] | |
with: | |
version: 'latest' | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: zola | |
- name: Build bundle | |
run: | | |
rm -rf dist/ | |
(cd www-zola && zola build --output-dir ../dist) | |
wasm-pack build --release --target web | |
# The generated WebAssembly | |
cp -r pkg dist | |
find dist -type d -print0 | xargs -0 chmod 755 | |
find dist -type f -print0 | xargs -0 chmod 644 | |
# Build pyodide (Python compiled to WASM) alongside our required Python libraries | |
# compiled to WASM (in particular those that include C code, such pycryptodome and | |
# protobuf). We need to build the construct package v2.8.8 (which is a dependency of | |
# pywidevine) specially, because it's not packaged as a wheel on pypi. | |
PYODIDE_DIST=`pwd`/dist/pyodide | |
mkdir -p $PYODIDE_DIST | |
TMPSRC=`mktemp -d /tmp/pyodide-buildXXXX` | |
# First build a whl for construct v2.8.8. It's required by the old version of pymp4 used | |
# in pywidevine, but is not available as a whl on pypi. | |
cd $TMPSRC | |
wget --quiet https://files.pythonhosted.org/packages/b6/2c/66bab4fef920ef8caa3e180ea601475b2cbbe196255b18f1c58215940607/construct-2.8.8.tar.gz | |
tar xzf construct-2.8.8.tar.gz | |
cd construct-2.8.8 | |
python3 setup.py bdist_wheel | |
cp dist/construct-2.8.8-py2.py3-none-any.whl $PYODIDE_DIST | |
echo === Content of PYODIDE_DIST directory: | |
ls -l $PYODIDE_DIST | |
cd $TMPSRC | |
echo === Fetching pyodide repository | |
git clone --quiet --recursive --depth 1 https://github.com/pyodide/pyodide.git | |
cd pyodide | |
# Build pyodide using emscripten, as per | |
# https://pyodide.org/en/latest/development/building-from-sources.html | |
podman run -ti --tty -v $PWD:/src \ | |
docker.io/pyodide/pyodide-env:20241106-chrome130-firefox132 \ | |
/bin/bash -c "PYODIDE_PACKAGES=\"micropip,pycryptodome,pyyaml,protobuf,requests,lzma,hashlib\" make" | |
# This leaves output files in $TMPSRC/pyodide/dist. We don't need all the built files, | |
# because for many necessary Python packages we can use the official whl tarballs. | |
# Copy only the necessary files to $PYODIDE_DIST. | |
cd $TMPSRC/pyodide/dist | |
cp ffi.d.ts $PYODIDE_DIST | |
cp package.json $PYODIDE_DIST | |
echo == protobuf4ls | |
ls protob* | |
cp protobuf-5*wasm32.whl $PYODIDE_DIST | |
cp pycryptodome-3*wasm32.whl $PYODIDE_DIST | |
cp pyodide.asm.js $PYODIDE_DIST | |
cp pyodide.asm.wasm $PYODIDE_DIST | |
cp pyodide.d.ts $PYODIDE_DIST | |
cp pyodide.js $PYODIDE_DIST | |
cp pyodide.js.map $PYODIDE_DIST | |
cp pyodide-lock.json $PYODIDE_DIST | |
cp pyodide.mjs $PYODIDE_DIST | |
cp pyodide.mjs.map $PYODIDE_DIST | |
cp python_stdlib.zip $PYODIDE_DIST | |
cp request*whl $PYODIDE_DIST | |
cp micropip* $PYODIDE_DIST | |
echo === Final content of PYODIDE_DIST directory | |
ls -l $PYODIDE_DIST | |
- uses: actions/configure-pages@v5 | |
- uses: actions/upload-pages-artifact@v3 | |
with: | |
path: './dist' | |
retention-days: 2 | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |