Merge pull request #3 from TimWillebrands/add-memory-to-ts-definitions #11
This file contains hidden or 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: Deploy Web Demo to GitHub Pages | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths: | |
| - "src/**" | |
| - "examples/web-demo/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - ".github/workflows/deploy-demo.yml" | |
| pull_request: | |
| branches: [main, master] | |
| paths: | |
| - "src/**" | |
| - "examples/web-demo/**" | |
| workflow_dispatch: | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - name: Cache Rust dependencies and tools | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| ~/.cargo/bin | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-tools-v1 | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install wasm-pack | |
| run: | | |
| # Only install if not already cached | |
| if [ ! -f ~/.cargo/bin/wasm-pack ]; then | |
| echo "Installing wasm-pack..." | |
| curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| else | |
| echo "wasm-pack already installed (cached)" | |
| fi | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| # - name: Setup Bun | |
| # uses: oven-sh/setup-bun@v1 | |
| # with: | |
| # bun-version: latest | |
| # - name: Install demo dependencies | |
| # working-directory: examples/web-demo | |
| # run: bun install | |
| - name: Build WASM module | |
| working-directory: examples/web-demo | |
| run: | | |
| echo "🔨 Building WASM module..." | |
| wasm-pack build \ | |
| --target web \ | |
| --out-dir examples/web-demo/pkg \ | |
| --release \ | |
| ../../ | |
| echo "📊 Build verification:" | |
| ls -la pkg/ | |
| echo "WASM size: $(du -h pkg/bresenham_lighting_engine_bg.wasm | cut -f1)" | |
| - name: Prepare static deployment | |
| working-directory: examples/web-demo | |
| run: | | |
| echo "📦 Preparing static deployment..." | |
| # Create deployment directory | |
| mkdir -p ../../dist | |
| # Copy HTML files | |
| cp index.html ../../dist/ | |
| cp test.html ../../dist/ | |
| # Copy CSS | |
| cp styles.css ../../dist/ | |
| # Copy Preact source directory | |
| cp -r src ../../dist/ | |
| # Copy WASM package | |
| cp -r pkg ../../dist/ | |
| # Create .nojekyll to disable Jekyll processing | |
| touch ../../dist/.nojekyll | |
| # Create a simple deployment info file | |
| cat > ../../dist/build-info.json << EOF | |
| { | |
| "build_time": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")", | |
| "commit_sha": "${{ github.sha }}", | |
| "ref": "${{ github.ref }}", | |
| "workflow_run": "${{ github.run_number }}" | |
| } | |
| EOF | |
| echo "✅ Deployment prepared:" | |
| ls -la ../../dist/ | |
| echo "📁 Source directory contents:" | |
| ls -la ../../dist/src/ | |
| echo "🧩 Components:" | |
| ls -la ../../dist/src/components/ | |
| echo "🪝 Hooks:" | |
| ls -la ../../dist/src/hooks/ | |
| - name: Upload deployment artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./dist | |
| deploy: | |
| # Only deploy on pushes to main/master, not on PRs | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Post deployment info | |
| run: | | |
| echo "🚀 Deployment completed!" | |
| echo "📍 Demo URL: ${{ steps.deployment.outputs.page_url }}" | |
| echo "🔧 Build info available at: ${{ steps.deployment.outputs.page_url }}build-info.json" |