Skip to content

Commit

Permalink
Add deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Canleskis committed Jan 14, 2024
1 parent 02a3262 commit 5c8c1d3
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions scripts/deploy_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions scripts/deploy_example.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions scripts/deploy_showcase.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion static/CNAME
Original file line number Diff line number Diff line change
@@ -1 +1 @@
particular.rs
canleskis.github.io/particular-website/

0 comments on commit 5c8c1d3

Please sign in to comment.