# Build the wasm web app and publish it to GitHub Pages on every release # (issue #45). No threads are used on wasm (rayon runs sequentially), so the # COOP/COEP headers GitHub Pages can't set are not needed. name: Deploy web (GitHub Pages) run-name: ${{ github.event.release.tag_name || github.ref_name }} Web on: release: types: [published] workflow_dispatch: permissions: contents: read pages: write id-token: write # Allow only one Pages deployment at a time. concurrency: group: pages cancel-in-progress: true jobs: build: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown - uses: Swatinem/rust-cache@v2 - name: Install trunk uses: taiki-e/install-action@v2 with: tool: trunk # The rust in index.html sets `data-cargo-no-default-features`, # so this drops the `solid3d` feature (truck-meshalgo → lzma-sys C deps # that can't cross-compile to wasm). `--public-url` matches the project # page sub-path: https://.github.io/OpenCADStudio/. - name: Build web bundle run: trunk build --release --public-url /OpenCADStudio/ # GitHub Pages runs Jekyll, which ignores files; opt out so the # wasm-bindgen output is served verbatim. - run: touch dist/.nojekyll # The web app can't call the Patreon API directly (CORS + the token would # be exposed in the bundle), so generate the supporters list server-side # here — token stays in the CI secret — and serve it next to the app. # The web build fetches `supporters.json` on the same origin. - name: Generate supporters.json env: OCS_PATREON_TOKEN: ${{ secrets.OCS_PATREON_TOKEN }} run: | if [ -z "$OCS_PATREON_TOKEN" ]; then echo '[]' > dist/supporters.json; exit 0 fi CID=$(curl -sf -H "Authorization: Bearer $OCS_PATREON_TOKEN" \ "https://www.patreon.com/api/oauth2/v2/campaigns" \ | jq -r '.data[0].id // empty' || true) if [ -z "$CID" ]; then echo '[]' > dist/supporters.json; exit 0 fi curl -sf -H "Authorization: Bearer $OCS_PATREON_TOKEN" \ "https://www.patreon.com/api/oauth2/v2/campaigns/$CID/members?fields%5Bmember%5D=full_name,patron_status,currently_entitled_amount_cents&page%5Bcount%5D=200" \ | jq -c '[.data[] | select(.attributes.patron_status=="active_patron") | select(.attributes.currently_entitled_amount_cents>0) | {name: .attributes.full_name, cents: .attributes.currently_entitled_amount_cents}] | sort_by(-.cents)' \ > dist/supporters.json || echo '[]' > dist/supporters.json echo "supporters: $(jq 'length' dist/supporters.json)" - uses: actions/upload-pages-artifact@v3 with: path: dist deploy: needs: build runs-on: ubuntu-22.04 environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - id: deployment uses: actions/deploy-pages@v4