chore: ci
This commit is contained in:
76
.github/workflows/build.yml
vendored
Normal file
76
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
name: Build WASM
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUST_VERSION: nightly
|
||||
EMSDK_VERSION: latest
|
||||
|
||||
jobs:
|
||||
build-wasm:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Install Rust nightly
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
toolchain: ${{ env.RUST_VERSION }}
|
||||
target: wasm32-unknown-emscripten
|
||||
|
||||
- name: Setup Emscripten
|
||||
uses: mymindstorm/setup-emsdk@v14
|
||||
with:
|
||||
version: ${{ env.EMSDK_VERSION }}
|
||||
actions-cache-folder: emsdk-cache
|
||||
|
||||
- name: Install CMake
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y cmake
|
||||
|
||||
- name: Clone Unicorn Engine
|
||||
id: clone-unicorn
|
||||
run: |
|
||||
git clone --depth 1 --branch tci-emscripten https://github.com/lbr77/unicorn.git ../unicorn
|
||||
echo "unicorn_hash=$(git -C ../unicorn rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache Unicorn build
|
||||
id: cache-unicorn
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ../unicorn/build
|
||||
key: unicorn-build-${{ steps.clone-unicorn.outputs.unicorn_hash }}-${{ runner.os }}
|
||||
|
||||
- name: Build Unicorn
|
||||
if: steps.cache-unicorn.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
bash script/rebuild-unicorn.sh
|
||||
env:
|
||||
UNICORN_DIR: ${{ github.workspace }}/../unicorn
|
||||
UNICORN_BUILD_DIR: ${{ github.workspace }}/../unicorn/build
|
||||
JOBS: 4
|
||||
|
||||
- name: Build WASM glue
|
||||
run: |
|
||||
bash script/build-glue.sh
|
||||
env:
|
||||
UNICORN_BUILD_DIR: ${{ github.workspace }}/../unicorn/build
|
||||
|
||||
- name: Upload WASM artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: anisette-wasm
|
||||
path: |
|
||||
dist/anisette_rs.js
|
||||
dist/anisette_rs.wasm
|
||||
dist/anisette_rs.node.js
|
||||
dist/anisette_rs.node.wasm
|
||||
retention-days: 7
|
||||
@@ -8,7 +8,7 @@ fi
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
TARGET_DIR="${ROOT_DIR}/../target/wasm32-unknown-emscripten/${BUILD_MODE}"
|
||||
DIST_DIR="${ROOT_DIR}/test/dist"
|
||||
DIST_DIR="${ROOT_DIR}/dist"
|
||||
EMSDK_DIR="${EMSDK:-/Users/libr/Desktop/Life/emsdk}"
|
||||
UNICORN_BUILD_DIR="${UNICORN_BUILD_DIR:-${ROOT_DIR}/../unicorn/build}"
|
||||
NODE_DIST_JS="${DIST_DIR}/anisette_rs.node.js"
|
||||
@@ -95,5 +95,8 @@ echo " ${DIST_DIR}/anisette_rs.wasm"
|
||||
echo " ${NODE_DIST_JS}"
|
||||
echo " ${NODE_DIST_WASM}"
|
||||
|
||||
# Copy to frontend if directory exists (skip in CI if not present)
|
||||
if [[ -d "${ROOT_DIR}/../../frontend/public/anisette" ]]; then
|
||||
cp "${DIST_DIR}/anisette_rs.js" "${ROOT_DIR}/../../frontend/public/anisette/anisette_rs.js"
|
||||
cp "${DIST_DIR}/anisette_rs.wasm" "${ROOT_DIR}/../../frontend/public/anisette/anisette_rs.wasm"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user