Build pyodide static site #11
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
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: | |
- name: checkout code | |
uses: actions/checkout@v4 | |
- uses: conda-incubator/setup-miniconda@v3 | |
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 | |
git clone -b main --single-branch https://github.com/criosx/molgroups | |
- name: Build bumps | |
run: | | |
source "$CONDA_PREFIX/lib/python${{ matrix.python-version }}/site-packages/emsdk/emsdk_env.sh" | |
cd bumps | |
pyodide build | |
pyodide py-compile dist | |
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 | |
pyodide py-compile dist | |
echo "REFL1D_DIST=$(realpath dist)" >> $GITHUB_ENV | |
echo "REFL1D_WHEEL_FILE=$(ls dist)" >> $GITHUB_ENV | |
- name: Build molgroups | |
run: | | |
cd molgroups | |
python -m build --wheel | |
echo "MOLGROUPS_DIST=$(realpath dist)" >> $GITHUB_ENV | |
echo "MOLGROUPS_WHEEL_FILE=$(ls dist)" >> $GITHUB_ENV | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
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 | |
npm link bumps-webview-client | |
working-directory: refl1d/refl1d/webview/client | |
- 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/ | |
cp $MOLGROUPS_DIST/$MOLGROUPS_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 |