Skip to content

Commit 047d32e

Browse files
committed
ci: add build config for more platforms
1 parent b93e8fe commit 047d32e

File tree

3 files changed

+66
-28
lines changed

3 files changed

+66
-28
lines changed

.github/workflows/CI.yml

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ jobs:
3636
build: |
3737
yarn build
3838
strip -x *.node
39-
- host: ubuntu-latest
40-
target: x86_64-unknown-linux-gnu
41-
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
42-
build: |-
43-
set -e &&
44-
yarn build --target x86_64-unknown-linux-gnu &&
45-
strip *.node
4639
- host: macos-latest
4740
target: aarch64-apple-darwin
4841
build: |
@@ -53,6 +46,43 @@ jobs:
5346
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
5447
yarn build --target aarch64-apple-darwin
5548
strip -x *.node
49+
- host: ubuntu-latest
50+
target: x86_64-unknown-linux-gnu
51+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
52+
build: |-
53+
set -e &&
54+
yarn build --target x86_64-unknown-linux-gnu &&
55+
strip *.node
56+
- host: ubuntu-latest
57+
target: 'x86_64-unknown-linux-musl'
58+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
59+
build: yarn build
60+
- host: ubuntu-latest
61+
target: aarch64-unknown-linux-gnu
62+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
63+
build: |-
64+
set -e &&
65+
apt install pkg-config libssl-dev -y &&
66+
yarn build --target aarch64-unknown-linux-gnu &&
67+
aarch64-unknown-linux-gnu-strip *.node
68+
- host: ubuntu-latest
69+
target: aarch64-unknown-linux-musl
70+
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
71+
build: |-
72+
set -e &&
73+
rustup target add aarch64-unknown-linux-musl &&
74+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc &&
75+
yarn build --target aarch64-unknown-linux-musl &&
76+
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
77+
- host: ubuntu-latest
78+
target: armv7-unknown-linux-gnueabihf
79+
setup: |
80+
sudo apt-get update
81+
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
82+
build: |-
83+
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc &&
84+
yarn build --target=armv7-unknown-linux-gnueabihf &&
85+
arm-linux-gnueabihf-strip *.node
5686
name: stable - ${{ matrix.settings.target }} - node@16
5787
runs-on: ${{ matrix.settings.host }}
5888
steps:
@@ -64,7 +94,6 @@ jobs:
6494
node-version: 16
6595
check-latest: true
6696
cache: yarn
67-
architecture: ${{ matrix.settings.architecture }}
6897
- name: Install
6998
uses: actions-rs/toolchain@v1
7099
if: ${{ !matrix.settings.docker }}
@@ -73,21 +102,18 @@ jobs:
73102
override: true
74103
toolchain: stable
75104
target: ${{ matrix.settings.target }}
76-
- name: Generate Cargo.lock
77-
uses: actions-rs/cargo@v1
78-
if: ${{ !matrix.settings.docker }}
79-
with:
80-
command: generate-lockfile
81105
- name: Cache cargo
82-
uses: actions/cache@v2
83-
with:
84-
path: ~/.cargo/registry
85-
key: ${{ matrix.settings.target }}-cargo-registry
86-
- name: Cache cargo index
87-
uses: actions/cache@v2
106+
uses: actions/cache@v3
88107
with:
89-
path: ~/.cargo/git
90-
key: ${{ matrix.settings.target }}-cargo-index
108+
path: |
109+
~/.cargo/registry/index/
110+
~/.cargo/registry/cache/
111+
~/.cargo/git/db/
112+
.cargo-cache/registry/index/
113+
.cargo-cache/registry/cache/
114+
.cargo-cache/git/db/
115+
target/
116+
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
91117
- name: Cache NPM dependencies
92118
uses: actions/cache@v2
93119
with:
@@ -97,8 +123,20 @@ jobs:
97123
run: ${{ matrix.settings.setup }}
98124
if: ${{ matrix.settings.setup }}
99125
shell: bash
126+
- name: Setup node x86
127+
if: matrix.settings.target == 'i686-pc-windows-msvc'
128+
run: yarn config set supportedArchitectures.cpu "ia32"
129+
shell: bash
100130
- name: Install dependencies
101131
run: yarn install
132+
- name: Setup node x86
133+
uses: actions/setup-node@v3
134+
if: matrix.settings.target == 'i686-pc-windows-msvc'
135+
with:
136+
node-version: 16
137+
check-latest: true
138+
cache: yarn
139+
architecture: x86
102140
- name: Build in docker
103141
uses: addnab/docker-run-action@v3
104142
if: ${{ matrix.settings.docker }}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"description": "node-unix-socket allows you to use SO_REUSEPORT, SOCK_SEQPACKET, SOCK_DGRAM in Node.js.",
1111
"scripts": {
1212
"artifacts": "napi artifacts",
13-
"build": "npm run build:ts && napi build --platform --js false --dts js/addon.d.ts",
14-
"build:release": "npm run build:ts && napi build --platform --release --js false --dts js/addon.d.ts",
13+
"build:debug": "npm run build:ts && napi build --js false --dts js/addon.d.ts --platform",
14+
"build": "npm run build:ts && napi build --platform --js false --dts js/addon.d.ts --release",
1515
"build:ts": "tsc -p tsconfig.json",
1616
"check_mem": "node --max-old-space-size=128 scripts/dgram_memory.js",
1717
"doc": "typedoc --excludePrivate --excludeInternal --excludeExternals js/index.ts",
@@ -37,7 +37,7 @@
3737
},
3838
"license": "MIT",
3939
"devDependencies": {
40-
"@napi-rs/cli": "^2.6.2",
40+
"@napi-rs/cli": "^2.10.3",
4141
"@types/jest": "^27.5.0",
4242
"@types/node": "^17.0.31",
4343
"jest": "^27.5.1",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,10 +509,10 @@
509509
"@jridgewell/resolve-uri" "^3.0.3"
510510
"@jridgewell/sourcemap-codec" "^1.4.10"
511511

512-
"@napi-rs/cli@^2.6.2":
513-
version "2.10.1"
514-
resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-2.10.1.tgz#1f332778e9c7aa18c2f59977cb90027f77d47d26"
515-
integrity sha512-Rscrg0BO4AKqFX2mKd8C68Wh3TkSHXqF2PZp+utVoLV+PTQnGVMwHedtIHBcFoq1Ij3I4yETMgSFSdAR+lp++Q==
512+
"@napi-rs/cli@^2.10.3":
513+
version "2.10.3"
514+
resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-2.10.3.tgz#61012d6a78eb8e8aefccbd1933f07b9bc9641c72"
515+
integrity sha512-J/3zqDX1VLhzl9RNpthAcCSLPaute7J7ImaP926xjJXAcfZmUM6QjJBCrvdMa3aGEfQ3TqDwidUnLj71JHW8QQ==
516516

517517
"@sinonjs/commons@^1.7.0":
518518
version "1.8.3"

0 commit comments

Comments
 (0)