diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..53a9666 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,43 @@ +name: Deploy + +on: + push: + branches: ["main"] + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Checkout Particular + uses: actions/checkout@v4 + with: + repository: canleskis/particular + path: particular + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + target: wasm32-unknown-unknown + + - uses: Swatinem/rust-cache@v2 + + - name: Setup wasm-bindgen + uses: jetli/wasm-bindgen-action@v0.2.0 + with: + version: "0.2.89" + + - name: Deploy Benchmarks + run: | + bash scripts/deploy_benchmarks.sh content/benchmarks + + - name: Deploy Examples + run: | + bash scripts/deploy_showcase.sh + + - name: Deploy Site + uses: shalzz/zola-deploy-action@v0.17.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/deploy_benchmarks.sh b/scripts/deploy_benchmarks.sh new file mode 100644 index 0000000..7e5a634 --- /dev/null +++ b/scripts/deploy_benchmarks.sh @@ -0,0 +1,14 @@ +# Add all the benchmarks to a list in single json file. + +out_dir=$1 +name=${2:-"benchmarks"} +particular_dir=${3:-"particular"} + +buffer="" + +for file in $particular_dir/particular/benches/results/*.json; do + buffer+=$(cat "$file") + buffer+="," +done + +echo "[${buffer%?}]" > $out_dir/$name.json diff --git a/scripts/deploy_example.sh b/scripts/deploy_example.sh new file mode 100644 index 0000000..abb9ed6 --- /dev/null +++ b/scripts/deploy_example.sh @@ -0,0 +1,20 @@ +path=$1 +out_dir=$2 +particular_dir=$3 + +metadata=$(grep -A3 "\[package.metadata.particular.rs\]" $path/Cargo.toml | grep -vE "^(#|\[)") + +if [ -n "$metadata" ]; then + name=$(basename $path) + + RUSTFLAGS='-C target-feature=+simd128' cargo build -p $name --release --target wasm32-unknown-unknown --manifest-path $particular_dir/Cargo.toml + wasm-bindgen --no-typescript --out-name example --out-dir $out_dir/$name --target web $particular_dir/target/wasm32-unknown-unknown/release/$name.wasm + + cp $path/preview.png $out_dir/$name/preview.png + cp -r $path/assets $out_dir/$name/assets 2>/dev/null + + echo '+++ +'"$metadata"' +template = "demo.html" ++++' >$out_dir/$name/index.md +fi diff --git a/scripts/deploy_showcase.sh b/scripts/deploy_showcase.sh new file mode 100644 index 0000000..b827ad5 --- /dev/null +++ b/scripts/deploy_showcase.sh @@ -0,0 +1,7 @@ +particular_dir=${1:-"particular"} + +for subfolder in particular/examples/*; do + if [ -d $subfolder ]; then + bash scripts/deploy_example.sh $subfolder content/demos $particular_dir + fi +done diff --git a/static/CNAME b/static/CNAME index b6e77a7..812e762 100644 --- a/static/CNAME +++ b/static/CNAME @@ -1 +1 @@ -particular.rs \ No newline at end of file +canleskis.github.io/particular-website/ \ No newline at end of file