feat: add a prepare script (#104) #952
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
paths-ignore: | |
- '**/*.md' | |
- '**/docs/**' | |
branches: | |
- main | |
- test-* | |
tags: | |
- v* | |
pull_request: | |
paths-ignore: | |
- '**/*.md' | |
- '**/docs/**' | |
workflow_dispatch: | |
env: | |
WASI_VERSION: '21' | |
WASI_VERSION_FULL: '21.0' | |
WASI_SDK_PATH: './wasi-sdk-21.0' | |
EM_VERSION: '3.1.44' | |
EM_CACHE_FOLDER: 'emsdk-cache' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- 'wasm32-unknown-emscripten' | |
- 'wasm64-unknown-emscripten' | |
- 'wasm32-unknown-unknown' | |
- 'wasm32-wasi' | |
- 'wasm32-wasi-threads' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Ninja | |
run: | | |
sudo apt-get update | |
sudo apt-get install ninja-build | |
- name: Setup Emscripten cache | |
if: ${{ contains(matrix.target, 'emscripten') }} | |
id: cache-system-libraries | |
uses: actions/cache@v3 | |
with: | |
path: ${{env.EM_CACHE_FOLDER}} | |
key: ${{env.EM_VERSION}}-${{ runner.os }}-${{ matrix.target }} | |
- uses: mymindstorm/setup-emsdk@v13 | |
if: ${{ contains(matrix.target, 'emscripten') }} | |
with: | |
version: ${{ env.EM_VERSION }} | |
# no-cache: true | |
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }} | |
# - uses: actions-rs/toolchain@v1 | |
# if: ${{ matrix.target == 'wasm32-unknown-unknown' || matrix.target == 'wasm32-wasi' }} | |
# with: | |
# toolchain: nightly | |
# default: true | |
# target: ${{ matrix.target }} | |
- name: Install wasi-sdk | |
if: ${{ matrix.target == 'wasm32-unknown-unknown' || matrix.target == 'wasm32-wasi' || matrix.target == 'wasm32-wasi-threads' }} | |
shell: bash | |
run: | | |
wget -q https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz | |
mkdir -p $WASI_SDK_PATH | |
tar zxvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz -C $WASI_SDK_PATH --strip 1 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '20.9.0' | |
registry-url: 'https://registry.npmjs.org' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: NPM Install | |
shell: bash | |
run: | | |
npm install -g node-gyp | |
npm install | |
- name: NPM Build | |
shell: bash | |
run: npm run build --workspaces --if-present | |
- name: Test Emscripten ESM library | |
shell: bash | |
run: npm run test -w packages/ts-transform-emscripten-esm-library | |
# - name: Lint | |
# run: npm run lint | |
- name: Test wasm32-wasi-threads | |
if: ${{ matrix.target == 'wasm32-wasi-threads' }} | |
run: | | |
npm run rebuild:wt -w packages/test | |
npm run test:wt -w packages/test | |
- name: Test wasm32-unknown-emscripten | |
if: ${{ matrix.target == 'wasm32-unknown-emscripten' }} | |
run: | | |
npm run test:version | |
npm run rebuild -w packages/test | |
npm run test -w packages/test | |
- name: Test wasm64-unknown-emscripten | |
if: ${{ matrix.target == 'wasm64-unknown-emscripten' }} | |
env: | |
MEMORY64: '1' | |
UV_THREADPOOL_SIZE: '2' | |
NODE_TEST_KNOWN_GLOBALS: '0' | |
run: | | |
node ./packages/test/script/build-emscripten.js Debug | |
node ./packages/test/script/test.js | |
- name: Test wasm32-wasi | |
if: ${{ matrix.target == 'wasm32-wasi' }} | |
run: | | |
npm run rebuild:w -w packages/test | |
npm run test:w -w packages/test | |
- name: Test wasm32-unknown-unknown | |
if: ${{ matrix.target == 'wasm32-unknown-unknown' }} | |
run: | | |
npm run rebuild:wasm32 -w packages/test | |
npm run test:wasm32 -w packages/test | |
release: | |
name: Release | |
if: ${{ startsWith(github.event.ref, 'refs/tags') }} | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Ninja | |
run: | | |
sudo apt-get update | |
sudo apt-get install ninja-build | |
- uses: mymindstorm/setup-emsdk@v13 | |
with: | |
version: ${{ env.EM_VERSION }} | |
# no-cache: true | |
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }} | |
- name: Install wasi-sdk | |
shell: bash | |
run: | | |
wget -q https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz | |
mkdir -p $WASI_SDK_PATH | |
tar zxvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz -C $WASI_SDK_PATH --strip 1 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '20.9.0' | |
registry-url: 'https://registry.npmjs.org' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: NPM Install | |
shell: bash | |
run: | | |
npm install -g node-gyp | |
npm install | |
- name: NPM Build | |
shell: bash | |
run: npm run build --workspaces --if-present | |
- name: Publish | |
run: | | |
node ./script/release.js | |
npm publish --ignore-scripts -w packages/runtime -w packages/node -w packages/emnapi -w packages/core | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
name: ${{ github.ref_name }} | |
draft: true | |
prerelease: false | |
generate_release_notes: true | |
files: ./script/emnapi.zip |