Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yisibl committed Jan 21, 2022
1 parent 22e10ee commit f7392fb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
67 changes: 38 additions & 29 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ jobs:
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
architecture: x64
docker: |
docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian
docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian builder
build: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build && strip *.node
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig
build: >-
rustup toolchain install $(cat ./rust-toolchain) &&
rustup target add x86_64-unknown-linux-gnu &&
yarn build --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
llvm-strip -x *.node
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
architecture: x64
docker: |
docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine
docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
build: docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build && strip *.node
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: yarn build
- host: macos-latest
target: aarch64-apple-darwin
build: |
Expand All @@ -68,13 +67,14 @@ jobs:
- host: ubuntu-latest
architecture: x64
target: aarch64-unknown-linux-gnu
setup: |
sudo apt-get update
sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu -y
build: |
yarn build --target=aarch64-unknown-linux-gnu
aarch64-linux-gnu-strip *.node
- host: ubuntu-latest
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig
build: >-
set -e &&
rustup toolchain install $(cat ./rust-toolchain) &&
rustup target add aarch64-unknown-linux-gnu &&
yarn build --target aarch64-unknown-linux-gnu --zig --zig-abi-suffix 2.17 &&
llvm-strip -x *.node
- host: ubuntu-18.04
architecture: x64
target: armv7-unknown-linux-gnueabihf
setup: |
Expand Down Expand Up @@ -107,11 +107,12 @@ jobs:
architecture: x64
target: aarch64-unknown-linux-musl
downloadTarget: aarch64-unknown-linux-musl
docker: |
docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder
build: |
docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "rustup toolchain install $(cat ./rust-toolchain) && rustup target add aarch64-unknown-linux-musl && yarn build --target=aarch64-unknown-linux-musl && /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node"
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: >-
set -e &&
rustup toolchain install $(cat ./rust-toolchain) &&
rustup target add aarch64-unknown-linux-musl &&
yarn build --target aarch64-unknown-linux-musl
- host: windows-latest
architecture: x64
target: aarch64-pc-windows-msvc
Expand All @@ -122,49 +123,57 @@ jobs:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
if: ${{ !matrix.settings.docker }}
with:
node-version: 16
check-latest: true
cache: yarn
architecture: ${{ matrix.settings.architecture }}
- name: Install
uses: actions-rs/toolchain@v1
if: ${{ !matrix.settings.docker }}
with:
profile: minimal
override: true
target: ${{ matrix.settings.target }}
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
if: ${{ !matrix.settings.docker }}
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ matrix.settings.target }}-node@16-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
key: ${{ matrix.settings.target }}-cargo-registry
- name: Cache cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ matrix.settings.target }}-node@16-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
key: ${{ matrix.settings.target }}-cargo-index
- name: Cache NPM dependencies
uses: actions/cache@v2
with:
path: node_modules
key: npm-cache-${{ matrix.settings.target }}-node@16-${{ hashFiles('yarn.lock') }}
- name: Pull latest image
run: ${{ matrix.settings.docker }}
env:
DOCKER_REGISTRY_URL: ghcr.io
if: ${{ matrix.settings.docker }}
key: npm-cache-build-${{ matrix.settings.target }}-node@16
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000

- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
with:
image: ${{ matrix.settings.docker }}
options: -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build
run: ${{ matrix.settings.build }}

- name: Build
run: ${{ matrix.settings.build }}
if: ${{ !matrix.settings.docker }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"devDependencies": {
"@napi-rs/canvas": "^0.1.19",
"@napi-rs/cli": "^2.3.0",
"@napi-rs/cli": "^2.4.2",
"@swc-node/register": "^1.4.2",
"@types/node": "^17.0.1",
"@types/sharp": "^0.29.5",
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2021-12-23
nightly-2022-01-19

0 comments on commit f7392fb

Please sign in to comment.