From d9a65e90e5f63e63b27efc1911f578c9686c88c9 Mon Sep 17 00:00:00 2001 From: Pranab Das <31024886+pranabdas@users.noreply.github.com> Date: Wed, 16 Nov 2022 00:55:12 +0000 Subject: [PATCH] deploy github pages --- .github/workflows/gh-pages-deploy.yml | 32 +++++++++++++++++ README.md | 17 +++++----- build.sh | 12 +++++++ package-lock.json | 1 + package.json | 1 + public/index.html | 49 +++++++-------------------- 6 files changed, 67 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/gh-pages-deploy.yml create mode 100644 build.sh diff --git a/.github/workflows/gh-pages-deploy.yml b/.github/workflows/gh-pages-deploy.yml new file mode 100644 index 0000000..284db79 --- /dev/null +++ b/.github/workflows/gh-pages-deploy.yml @@ -0,0 +1,32 @@ +name: Deploy gh-pages + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-22.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + + steps: + - uses: actions/checkout@v3 + + - name: Prepare Node environment + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Prepare and build everything + run: bash build.sh + + - name: Deploy on gh-pages + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./build + user_name: 'github-actions[bot]' + user_email: 'github-actions[bot]@users.noreply.github.com' diff --git a/README.md b/README.md index d723235..41f5e96 100644 --- a/README.md +++ b/README.md @@ -17,21 +17,22 @@ bash setup.sh Or create new rust lib: ```console cargo new rust-libs --lib +cd rust-libs cargo add wasm-bindgen ``` -Move in to our `rust-libs` directory and build the rust libs: -```console -cd wasm-rust-libs -wasm-pack build --target web -``` - -Notice the `Cargo.toml` spec and add rust byproducts in `.gitignore`. +Change crate-type in `Cargo.toml` and add rust byproducts in `.gitignore`. ```rs [lib] crate-type = ["cdylib"] ``` -Run: + +Build the rust libs: +```console +wasm-pack build --target web +``` + +Install/add package to npm: ``` npm i ./rust-libs/pkg ``` diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..8bb73cb --- /dev/null +++ b/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash +sudo apt update +sudo apt install -y curl +curl https://sh.rustup.rs -sSf | sh -s -- -y +source $HOME/.cargo/env +curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | bash +cargo install cargo-generate +cd rust-libs +wasm-pack build --target web +cd .. +npm i +npm run build diff --git a/package-lock.json b/package-lock.json index e3f6d54..344b9a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,6 @@ { "name": "wasm-rust-react", + "homepage": ".", "version": "0.1.0", "lockfileVersion": 2, "requires": true, diff --git a/package.json b/package.json index 5bb3ae9..7235754 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "wasm-rust-react", + "homepage": ".", "version": "0.1.0", "private": true, "dependencies": { diff --git a/public/index.html b/public/index.html index aa069f2..5e9e54c 100644 --- a/public/index.html +++ b/public/index.html @@ -1,43 +1,18 @@ - - - - - - - - - - - React App - - - -
- -