2.0.1 #396
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: CI | |
env: | |
MACOSX_DEPLOYMENT_TARGET: '10.13' | |
on: | |
push: | |
branches: | |
- main | |
tags-ignore: | |
- '**' | |
paths: | |
- '**/src/**/*.rs' | |
- '**/*.cjs' | |
- '**/*.js' | |
- '**/*.ts' | |
- '**/*.mjs' | |
- '**/*.json' | |
- 'core/README.md' | |
- 'core/bin/codepoints.bin' | |
- 'bindings/native/test.c' | |
- 'bindings/native/decancer.h' | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
setup: | |
name: Setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
check-latest: true | |
- name: Setup | |
id: setup | |
run: node scripts/ci_setup.mjs | |
env: | |
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
outputs: | |
release: ${{ steps.setup.outputs.release }} | |
core_affected: ${{ steps.setup.outputs.core_affected }} | |
node_affected: ${{ steps.setup.outputs.node_affected }} | |
wasm_affected: ${{ steps.setup.outputs.wasm_affected }} | |
native_affected: ${{ steps.setup.outputs.native_affected }} | |
core: | |
name: Test core | |
runs-on: ubuntu-latest | |
needs: | |
- setup | |
if: ${{ needs.setup.outputs.release != 'null' || needs.setup.outputs.core_affected == 'true' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ATiltedTree/setup-rust@v1 | |
with: | |
rust-version: stable | |
- uses: actions/setup-node@v3 | |
if: ${{ !matrix.settings.docker }} | |
with: | |
node-version: 20 | |
check-latest: true | |
- name: Ensure no_std is working | |
working-directory: core | |
run: cargo c --no-default-features | |
- name: Run cargo test | |
working-directory: core | |
run: cargo test --all-features | |
native: | |
strategy: | |
fail-fast: true | |
matrix: | |
settings: | |
- host: macos-latest | |
target: x86_64-apple-darwin | |
build: | | |
cargo build --release | |
strip -x ./target/release/libdecancer.dylib | |
mv ./target/release/libdecancer.dylib ../../artifacts | |
- host: windows-latest | |
build: | | |
cargo build --release | |
mv ./target/release/decancer.dll ../../artifacts | |
mv ./target/release/decancer.dll.lib ../../artifacts/decancer.lib | |
target: x86_64-pc-windows-msvc | |
- host: windows-latest | |
build: | | |
cargo build --release --target i686-pc-windows-msvc | |
mv ./target/i686-pc-windows-msvc/release/decancer.dll ../../artifacts | |
mv ./target/i686-pc-windows-msvc/release/decancer.dll.lib ../../artifacts/decancer.lib | |
target: i686-pc-windows-msvc | |
- host: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian | |
build: | | |
cargo build --release --target x86_64-unknown-linux-gnu | |
strip ./target/x86_64-unknown-linux-gnu/release/libdecancer.so | |
mv ./target/x86_64-unknown-linux-gnu/release/libdecancer.so ../../artifacts | |
- host: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine | |
build: | | |
cargo build --release | |
strip ./target/release/libdecancer.so | |
mv ./target/release/libdecancer.so ../../artifacts | |
- host: macos-latest | |
target: aarch64-apple-darwin | |
build: | | |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; | |
export CC=$(xcrun -f clang); | |
export CXX=$(xcrun -f clang++); | |
SYSROOT=$(xcrun --sdk macosx --show-sdk-path); | |
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; | |
cargo build --release --target aarch64-apple-darwin | |
strip -x ./target/aarch64-apple-darwin/release/libdecancer.dylib | |
mv ./target/aarch64-apple-darwin/release/libdecancer.dylib ../../artifacts | |
- host: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 | |
build: | | |
cargo build --release --target aarch64-unknown-linux-gnu | |
aarch64-unknown-linux-gnu-strip ./target/aarch64-unknown-linux-gnu/release/libdecancer.so | |
mv ./target/aarch64-unknown-linux-gnu/release/libdecancer.so ../../artifacts | |
- host: ubuntu-latest | |
target: armv7-unknown-linux-gnueabihf | |
build: | | |
sudo apt-get update | |
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y | |
cargo build --release --target=armv7-unknown-linux-gnueabihf | |
arm-linux-gnueabihf-strip ./target/armv7-unknown-linux-gnueabihf/release/libdecancer.so | |
mv ./target/armv7-unknown-linux-gnueabihf/release/libdecancer.so ../../artifacts | |
- host: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine | |
build: | | |
rustup target add aarch64-unknown-linux-musl | |
cargo build --release --target aarch64-unknown-linux-musl | |
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip ./target/aarch64-unknown-linux-musl/release/libdecancer.so | |
mv ./target/aarch64-unknown-linux-musl/release/libdecancer.so ../../artifacts | |
- host: windows-latest | |
target: aarch64-pc-windows-msvc | |
build: | | |
cargo build --release --target aarch64-pc-windows-msvc | |
mv ./target/aarch64-pc-windows-msvc/release/decancer.dll ./artifacts | |
mv ./target/aarch64-pc-windows-msvc/release/decancer.dll.lib ../../artifacts/decancer.lib | |
needs: | |
- setup | |
- core | |
if: ${{ always() && (needs.setup.outputs.release != 'null' || needs.setup.outputs.native_affected == 'true') }} | |
name: Build native bindings on ${{ matrix.settings.target }} | |
runs-on: ${{ matrix.settings.host }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Rust | |
uses: actions-rs/toolchain@v1 | |
if: ${{ !matrix.settings.docker }} | |
with: | |
profile: minimal | |
override: true | |
toolchain: stable | |
target: ${{ matrix.settings.target }} | |
- uses: goto-bus-stop/setup-zig@v2 | |
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} | |
with: | |
version: 0.10.0 | |
- run: mkdir artifacts | |
shell: bash | |
- name: Build in docker | |
uses: addnab/docker-run-action@v3 | |
if: ${{ matrix.settings.docker }} | |
with: | |
image: ${{ matrix.settings.docker }} | |
options: '--user 0:0 -v ${{ github.workspace }}/native/.cargo-cache/git/db:/root/.cargo/git/db -v ${{ github.workspace }}/bindings/native/.cargo/registry/cache:/root/.cargo/registry/cache -v ${{ github.workspace }}/bindings/native/.cargo/registry/index:/root/.cargo/registry/index -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace}}/bindings/native' | |
run: ${{ matrix.settings.build }} | |
- name: Build | |
working-directory: bindings/native | |
run: ${{ matrix.settings.build }} | |
if: ${{ !matrix.settings.docker }} | |
shell: bash | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: native-${{ matrix.settings.target }} | |
path: ./artifacts/** | |
if-no-files-found: error | |
native-test: | |
name: Test native bindings | |
needs: | |
- setup | |
- native | |
if: ${{ always() && (needs.setup.outputs.release != 'null' || needs.setup.outputs.native_affected == 'true') }} | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: native-x86_64-pc-windows-msvc | |
path: bindings/native | |
- name: Compile and run tests | |
working-directory: bindings/native | |
run: | | |
cl.exe /MD /nologo test.c decancer.lib | |
.\test.exe | |
node: | |
strategy: | |
fail-fast: true | |
matrix: | |
settings: | |
- host: macos-latest | |
target: x86_64-apple-darwin | |
build: | | |
yarn build | |
strip -x *.node | |
- host: windows-latest | |
build: yarn build | |
target: x86_64-pc-windows-msvc | |
- host: windows-latest | |
build: yarn build --target i686-pc-windows-msvc | |
target: i686-pc-windows-msvc | |
- host: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian | |
build: | | |
yarn build --target x86_64-unknown-linux-gnu | |
strip *.node | |
- host: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine | |
build: | | |
yarn build | |
strip *.node | |
- host: macos-latest | |
target: aarch64-apple-darwin | |
build: | | |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; | |
export CC=$(xcrun -f clang); | |
export CXX=$(xcrun -f clang++); | |
SYSROOT=$(xcrun --sdk macosx --show-sdk-path); | |
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; | |
yarn build --target aarch64-apple-darwin | |
strip -x *.node | |
- host: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 | |
build: | | |
yarn build --target aarch64-unknown-linux-gnu | |
aarch64-unknown-linux-gnu-strip *.node | |
- host: ubuntu-latest | |
target: armv7-unknown-linux-gnueabihf | |
build: | | |
sudo apt-get update | |
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y | |
yarn build --target=armv7-unknown-linux-gnueabihf | |
arm-linux-gnueabihf-strip *.node | |
- host: ubuntu-latest | |
target: aarch64-linux-android | |
build: | | |
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" | |
export CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" | |
export CXX="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++" | |
export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}" | |
yarn build --target aarch64-linux-android | |
llvm-strip *.node | |
- host: ubuntu-latest | |
target: armv7-linux-androideabi | |
build: | | |
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang" | |
export CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang" | |
export CXX="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang++" | |
export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}" | |
yarn build --target armv7-linux-androideabi | |
llvm-strip *.node | |
- host: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine | |
build: | | |
rustup target add aarch64-unknown-linux-musl | |
yarn build --target aarch64-unknown-linux-musl | |
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node | |
- host: windows-latest | |
target: aarch64-pc-windows-msvc | |
build: yarn build --target aarch64-pc-windows-msvc | |
needs: | |
- setup | |
- core | |
if: ${{ always() && (needs.setup.outputs.release != 'null' || needs.setup.outputs.node_affected == 'true') }} | |
name: Build node bindings on ${{ matrix.settings.target }} | |
runs-on: ${{ matrix.settings.host }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
if: ${{ !matrix.settings.docker }} | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: yarn | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
if: ${{ !matrix.settings.docker }} | |
with: | |
profile: minimal | |
override: true | |
toolchain: stable | |
target: ${{ matrix.settings.target }} | |
- uses: goto-bus-stop/setup-zig@v2 | |
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} | |
with: | |
version: 0.10.0 | |
- name: Configure architecture to use with node | |
if: matrix.settings.target == 'i686-pc-windows-msvc' | |
run: yarn config set supportedArchitectures.cpu "ia32" | |
shell: bash | |
- uses: actions/setup-node@v3 | |
if: matrix.settings.target == 'i686-pc-windows-msvc' | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: yarn | |
architecture: x86 | |
- name: Install dependencies | |
working-directory: bindings/node | |
run: yarn install | |
- name: Build in docker | |
uses: addnab/docker-run-action@v3 | |
if: ${{ matrix.settings.docker }} | |
with: | |
image: ${{ matrix.settings.docker }} | |
options: '--user 0:0 -v ${{ github.workspace }}/node/.cargo-cache/git/db:/root/.cargo/git/db -v ${{ github.workspace }}/bindings/node/.cargo/registry/cache:/root/.cargo/registry/cache -v ${{ github.workspace }}/bindings/node/.cargo/registry/index:/root/.cargo/registry/index -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace}}/bindings/node' | |
run: ${{ matrix.settings.build }} | |
- name: Build | |
working-directory: bindings/node | |
run: ${{ matrix.settings.build }} | |
if: ${{ !matrix.settings.docker }} | |
shell: bash | |
- name: Move artifact | |
run: mv ./bindings/node/decancer.*.node . | |
shell: bash | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: node-${{ matrix.settings.target }} | |
path: decancer.*.node | |
if-no-files-found: error | |
node-test: | |
name: Test node bindings | |
needs: | |
- setup | |
- node | |
if: ${{ always() && (needs.setup.outputs.release != 'null' || needs.setup.outputs.node_affected == 'true') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: yarn | |
- name: Install dependencies | |
working-directory: bindings/node | |
run: yarn install | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: node-x86_64-unknown-linux-gnu | |
path: bindings/node | |
- run: ls -R . | |
- name: Test bindings | |
working-directory: bindings/node | |
run: yarn test | |
wasm: | |
name: Build and test wasm | |
runs-on: ubuntu-latest | |
needs: | |
- setup | |
- core | |
if: ${{ always() && (needs.setup.outputs.release != 'null' || needs.setup.outputs.wasm_affected == 'true') }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ATiltedTree/setup-rust@v1 | |
with: | |
rust-version: stable | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
check-latest: true | |
- name: Setup wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Build wasm | |
working-directory: bindings/wasm | |
run: | | |
wasm-pack build --no-typescript --release -t web | |
mv ./pkg/decancer_wasm_bg.wasm ../../decancer.wasm | |
- name: Test wasm | |
working-directory: bindings/wasm/tests | |
run: | | |
npm i | |
node . | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wasm | |
path: | | |
decancer.wasm | |
prettier: | |
name: Lint and prettier files | |
runs-on: ubuntu-latest | |
needs: | |
- setup | |
- wasm | |
if: ${{ always() }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ATiltedTree/setup-rust@v1 | |
with: | |
rust-version: stable | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
check-latest: true | |
- name: Prettier everything | |
run: node scripts/pretty.mjs | |
- name: Download wasm artifact | |
if: ${{ needs.setup.outputs.wasm_affected == 'true' || needs.setup.outputs.release != 'null' }} | |
uses: actions/download-artifact@v3 | |
with: | |
name: wasm | |
path: bindings/wasm/bin | |
- name: Commit | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: 'chore: prettier and update wasm' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Deploy to GitHub Pages | |
if: ${{ needs.setup.outputs.wasm_affected == 'true' || needs.setup.outputs.release != 'null' }} | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: '.' | |
- name: Remove wasm artifact | |
if: ${{ needs.setup.outputs.wasm_affected == 'true' || needs.setup.outputs.release != 'null' }} | |
uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: wasm | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
needs: | |
- setup | |
- node-test | |
- native-test | |
- prettier | |
if: ${{ always() && needs.setup.outputs.release != 'null' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: yarn | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Modify artifacts | |
run: node scripts/ci_artifacts.mjs | |
- name: Install dependencies | |
working-directory: bindings/node | |
run: yarn install | |
- name: Move artifacts | |
working-directory: bindings/node | |
run: yarn artifacts | |
- name: Copy README.md | |
working-directory: bindings/node | |
run: cp ../../core/README.md . | |
- name: Publish | |
working-directory: bindings/node | |
run: | | |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | |
npm publish --access public | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create Tag | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
message: "This is the GitHub Release for decancer v${{ needs.setup.outputs.release }}." | |
tag: "v${{ needs.setup.outputs.release }}" | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
body: "This is the GitHub Release for decancer v${{ needs.setup.outputs.release }}." | |
draft: false | |
prerelease: false | |
files: "*.zip" | |
tag_name: "v${{ needs.setup.outputs.release }}" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
env: | |
GITHUB_REPOSITORY: null8626/decancer |