Skip to content

Build pyodide static site #2

Build pyodide static site

Build pyodide static site #2

name: Build pyodide static site
on:
workflow_dispatch:
jobs:
# Build job
build:
# <Not provided for brevity>
# At a minimum this job should upload artifacts using actions/upload-pages-artifact
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
node-version: [18.x]
python-version: ["3.11"]
steps:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
activate-environment: pyodide
use-mamba: true
- name: Setup pyodide environment
run: |
mamba install -y emsdk pyodide-build
mamba list
echo $PATH
PYODIDE_EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version)
emsdk install ${PYODIDE_EMSCRIPTEN_VERSION}
emsdk activate ${PYODIDE_EMSCRIPTEN_VERSION}
source "$CONDA_PREFIX/lib/python${{ matrix.python-version }}/site-packages/emsdk/emsdk_env.sh"
- name: Clone git repos
run: |
git clone -b webview --single-branch https://github.com/bumps/bumps
git clone -b webview --single-branch https://github.com/reflectometry/refl1d
- name: Build bumps
run: |
cd bumps
python setup.py bdist_wheel
echo "BUMPS_DIST=$(realpath dist)" >> $GITHUB_ENV
echo "BUMPS_WHEEL_FILE=$(ls dist)" >> $GITHUB_ENV
- name: Build refl1d
run: |
source "$CONDA_PREFIX/lib/python${{ matrix.python-version }}/site-packages/emsdk/emsdk_env.sh"
cd refl1d
BUILD_EXTENSION=True pyodide build
echo "REFL1D_DIST=$(realpath dist)" >> $GITHUB_ENV
echo "REFL1D_WHEEL_FILE=$(ls dist)" >> $GITHUB_ENV
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: initialize bumps client
run: |
npm i
npm link
working-directory: bumps/bumps/webview/client
- name: initialize refl1d client
run: |
npm i
npm link
working-directory: refl1d/refl1d/webview/client
- name: checkout code
uses: actions/checkout@v4
- name: npm initialize self
run: |
npm i
npm link bumps-webview-client
npm link refl1d-webview-client
- name: build client
id: build_client
run: |
mkdir -p public/wheels
cp $BUMPS_DIST/$BUMPS_WHEEL_FILE public/wheels/
cp $REFL1D_DIST/$REFL1D_WHEEL_FILE public/wheels/
rm -rf dist
npm run build
echo "deploy_path=$(realpath dist)" >> $GITHUB_OUTPUT
env:
CI: ""
- name: Upload pages artifact client artifact
uses: actions/[email protected]
with:
path: ${{ steps.build_client.outputs.deploy_path }}
# Deploy job
deploy:
# Add a dependency to the build job
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4