Skip to content

Add Schist Cloud integration for desktop and WASM #61

Add Schist Cloud integration for desktop and WASM

Add Schist Cloud integration for desktop and WASM #61

Workflow file for this run

name: Web
on:
push:
branches: [main]
pull_request:
# Only when something the web build ships could have changed. That is
# most of the tree — the wasm is the whole editor — but not the
# desktop-only corners.
paths:
- "crates/**"
- "plugins/**"
- "web/**"
- "tools/web-build.sh"
- "Cargo.*"
- ".cargo/**"
- "wrangler.jsonc"
- ".github/workflows/web.yml"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
# Build scripts still compile for the host, and the host target's
# linker settings in .cargo/config.toml name clang and mold.
- name: Linux system deps
run: |
sudo apt-get update
sudo apt-get install -y clang mold
- uses: Swatinem/rust-cache@v2
# The CLI must match the wasm-bindgen crate in Cargo.lock exactly —
# tools/web-build.sh refuses a skew — so the version is read from
# the lock rather than pinned a second time here.
- name: Install wasm-bindgen-cli
run: |
set -euo pipefail
version=$(python3 -c '
import re
lock = open("Cargo.lock").read()
print(re.search(r"name = \"wasm-bindgen\"\nversion = \"([^\"]+)\"", lock).group(1))')
echo "wasm-bindgen $version"
curl -sSfL "https://github.com/rustwasm/wasm-bindgen/releases/download/${version}/wasm-bindgen-${version}-x86_64-unknown-linux-musl.tar.gz" \
| tar xz --strip-components=1 -C /usr/local/bin --wildcards '*/wasm-bindgen'
# Ubuntu's packaged binaryen is 108, which tools/web-build.sh
# refuses (it corrupts the externref table; see the script), so a
# known-good release is fetched instead.
- name: Install binaryen
run: |
set -euo pipefail
curl -sSfL "https://github.com/WebAssembly/binaryen/releases/download/version_123/binaryen-version_123-x86_64-linux.tar.gz" \
| tar xz -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/binaryen-version_123/bin" >> "$GITHUB_PATH"
- name: Build dist/web
run: ./tools/web-build.sh
# The deployable directory, inspectable from any run — a PR's build
# can be downloaded and served locally without deploying anything.
- uses: actions/upload-artifact@v4
with:
name: schist-web
path: dist/web
if-no-files-found: error
# Only a push to main deploys, and only when the repository has the
# Cloudflare credentials. A fork (or this repository before the
# secrets exist) builds everything above and simply stops here:
# CLOUDFLARE_API_TOKEN an API token with Workers Scripts:Edit,
# plus the schist.app zone (the custom
# domain needs DNS and certificates)
# CLOUDFLARE_ACCOUNT_ID the account the schist.app zone lives in
- name: Deploy to try.schist.app
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
if [ -z "$CLOUDFLARE_API_TOKEN" ]; then
echo 'no CLOUDFLARE_API_TOKEN secret; skipping the deploy'
exit 0
fi
npx --yes wrangler@4 deploy