Skip to content

Migrate to napi-rs implementation #55

Migrate to napi-rs implementation

Migrate to napi-rs implementation #55

Workflow file for this run

name: CI

Check failure on line 1 in .github/workflows/CI.yml

View workflow run for this annotation

GitHub Actions / CI

Invalid workflow file

The workflow is not valid. .github/workflows/CI.yml: Unexpected tag '!contains('
env:
DEBUG: napi:*
APP_NAME: xdelta3-node
RUST_BACKTRACE: full
permissions:
contents: write
id-token: write
"on":
push:
branches:
- main
tags-ignore:
- "**"
paths-ignore:
- "**/*.md"
- LICENSE
- "**/*.gitignore"
- .editorconfig
- docs/**
pull_request: null
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
- target: x86_64-apple-darwin
build: yarn build --target x86_64-apple-darwin
- target: aarch64-apple-darwin
build: yarn build --target aarch64-apple-darwin
- target: x86_64-unknown-linux-gnu
build: yarn build --target x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
build: yarn build --target aarch64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
build: yarn build --target x86_64-unknown-linux-musl
- target: aarch64-unknown-linux-musl
build: yarn build --target aarch64-unknown-linux-musl
- target: x86_64-pc-windows-msvc
build: yarn build --target x86_64-pc-windows-msvc
- target: aarch64-pc-windows-msvc
build: yarn build --target aarch64-pc-windows-msvc
runs-on: ubuntu-latest
name: Build - ${{ matrix.settings.target }}
steps:
- uses: actions/checkout@v4
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo
${{ github.workspace }}/.xwin
~/.napi-rs
./target
key: ${{ matrix.settings.target }}-cargo-cache
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.settings.target }}
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: Install ziglang
uses: mlugg/setup-zig@v1
with:
version: 0.13.0
- name: Install libclang-dev
run: sudo apt install libclang-dev
shell: bash
- name: Install cargo toolchains for windows
if: contains( ${{matrix.settings.target}}, 'msvc')
uses: taiki-e/install-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tool: cargo-xwin
- name: Install cargo toolchains for linux/unix
if: !contains( ${{matrix.settings.target}}, 'msvc')
uses: taiki-e/install-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tool: cargo-zigbuild
- name: Install rupstup target
run: rustup target add ${{ matrix.settings.target }}
shell: bash
- run: yarn install
- name: Build
run: CARGO=cargo-zigbuild ${{ matrix.settings.build }}
if: !contains( ${{matrix.settings.target}}, 'msvc')
- name: Build
run: CARGO=cargo-xwin ${{ matrix.settings.build }}
if: contains( ${{matrix.settings.target}}, 'msvc')
env:
XWIN_CACHE_DIR: ${{ github.workspace }}/.xwin
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: ${{ env.APP_NAME }}.*.node
if-no-files-found: error
test-linux-x64-musl-binding:
name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
node:
- "18"
- "20"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn
- name: Install dependencies
run: |
yarn config set supportedArchitectures.libc "musl"
yarn install
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-x86_64-unknown-linux-musl
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Test bindings
run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-alpine yarn test
test-linux-aarch64-gnu-binding:
name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
needs:
- build
strategy:
fail-fast: false
matrix:
node:
- "18"
- "20"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-unknown-linux-gnu
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Install dependencies
run: |
yarn config set supportedArchitectures.cpu "arm64"
yarn config set supportedArchitectures.libc "glibc"
yarn install
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:${{ matrix.node }}-slim
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build"
run: |
set -e
yarn test
ls -la
test-linux-aarch64-musl-binding:
name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-aarch64-unknown-linux-musl
path: .
- name: List packages
run: ls -R .
shell: bash
- name: Install dependencies
run: |
yarn config set supportedArchitectures.cpu "arm64"
yarn config set supportedArchitectures.libc "musl"
yarn install
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: node:lts-alpine
options: "--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build"
run: |
set -e
yarn test
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- test-linux-x64-musl-binding
- test-linux-aarch64-gnu-binding
- test-linux-aarch64-musl-binding
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Install dependencies
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Move artifacts
run: yarn artifacts
- name: List packages
run: ls -R ./npm
shell: bash
- name: Publish
run: |
npm config set provenance true
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
else
echo "Not a release, skipping publish"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}