|
| 1 | +name: build and deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + pages: write |
| 13 | + id-token: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + - name: Github-page |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v5 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Install mamba |
| 31 | + uses: mamba-org/setup-micromamba@v2 |
| 32 | + with: |
| 33 | + environment-file: environment-wasm-build.yml |
| 34 | + init-shell: bash |
| 35 | + environment-name: xeus-python-wasm-build |
| 36 | + |
| 37 | + - name: Set ncpus |
| 38 | + run: echo "ncpus=$(nproc --all)" >> $GITHUB_ENV |
| 39 | + |
| 40 | + - name: Build xeus-python |
| 41 | + shell: bash -l {0} |
| 42 | + run: | |
| 43 | + micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32 |
| 44 | + |
| 45 | + set -eux |
| 46 | + |
| 47 | + export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-python-wasm-host |
| 48 | + echo "PREFIX=$PREFIX" >> $GITHUB_ENV |
| 49 | + |
| 50 | + emcmake cmake . \ |
| 51 | + -DCMAKE_BUILD_TYPE=Release \ |
| 52 | + -DCMAKE_PREFIX_PATH="$PREFIX" \ |
| 53 | + -DCMAKE_SYSTEM_PREFIX_PATH="$PREFIX" \ |
| 54 | + -DCMAKE_INSTALL_PREFIX="$PREFIX" \ |
| 55 | + -DCMAKE_FIND_ROOT_PATH="$PREFIX" \ |
| 56 | + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ |
| 57 | + -DCMAKE_VERBOSE_MAKEFILE=ON |
| 58 | + |
| 59 | + emmake make -j${{ env.ncpus }} install |
| 60 | + |
| 61 | + - name: Jupyter Lite integration |
| 62 | + shell: bash -l {0} |
| 63 | + run: | |
| 64 | + jupyter lite build \ |
| 65 | + --XeusAddon.prefix=${{ env.PREFIX }} \ |
| 66 | + --XeusAddon.mounts=$PREFIX/share/xeus-python:/share/xeus-python \ |
| 67 | + --contents notebooks/xeus-python.ipynb \ |
| 68 | + --output-dir dist |
| 69 | + |
| 70 | + - name: Upload artifact |
| 71 | + uses: actions/upload-pages-artifact@v4 |
| 72 | + with: |
| 73 | + path: ./dist |
| 74 | + |
| 75 | + deploy: |
| 76 | + needs: build |
| 77 | + if: github.ref == 'refs/heads/main' |
| 78 | + permissions: |
| 79 | + pages: write |
| 80 | + id-token: write |
| 81 | + |
| 82 | + environment: |
| 83 | + name: github-pages |
| 84 | + url: ${{ steps.deployment.outputs.page_url }} |
| 85 | + |
| 86 | + runs-on: ubuntu-latest |
| 87 | + steps: |
| 88 | + - name: Deploy to GitHub Pages |
| 89 | + id: deployment |
| 90 | + uses: actions/deploy-pages@v4 |
0 commit comments