Skip to content

Commit ddffc4f

Browse files
authored
Build and package binaries with prebuildify instead of node-pre-gyp (#184)
* Use prebuildify to package binaries * Deprecate node-pre-gyp
1 parent feeec89 commit ddffc4f

File tree

13 files changed

+1900
-966
lines changed

13 files changed

+1900
-966
lines changed

.github/workflows/builds.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os.host }}
12+
strategy:
13+
matrix:
14+
node: [14, 16, 18]
15+
build_type: ["debug", "release"]
16+
os:
17+
- name: darwin
18+
architecture: x86-64
19+
host: macos-10.15
20+
21+
- name: linux
22+
architecture: x86-64
23+
host: ubuntu-20.04
24+
25+
name: ${{ matrix.os.name }}-${{ matrix.os.architecture }}-node${{ matrix.node }}-${{ matrix.build_type }} test
26+
steps:
27+
- uses: actions/checkout@v3
28+
- uses: actions/setup-node@v3
29+
with:
30+
node-version: ${{ matrix.node }}
31+
32+
- name: Test
33+
run: |
34+
npm ci
35+
./scripts/setup.sh --config local.env
36+
source local.env
37+
make ${{ matrix.build_type }}
38+
npm test
39+
40+
asan-build-test:
41+
runs-on: ubuntu-20.04
42+
name: ASAN toolset test
43+
env:
44+
BUILDTYPE: debug
45+
TOOLSET: asan
46+
steps:
47+
- uses: actions/checkout@v3
48+
- uses: actions/setup-node@v3
49+
with:
50+
node-version: "14"
51+
52+
- name: Test
53+
run: |
54+
npm ci
55+
./scripts/setup.sh --config local.env
56+
source local.env
57+
export CXXFLAGS="${MASON_SANITIZE_CXXFLAGS} -fno-sanitize-recover=all"
58+
export LDFLAGS="${MASON_SANITIZE_LDFLAGS}"
59+
make ${BUILDTYPE}
60+
export LD_PRELOAD=${MASON_LLVM_RT_PRELOAD}
61+
export ASAN_OPTIONS=fast_unwind_on_malloc=0:${ASAN_OPTIONS}
62+
npm test
63+
unset LD_PRELOAD
64+
65+
g-build-test:
66+
runs-on: ubuntu-20.04
67+
name: G++ build test
68+
env:
69+
BUILDTYPE: debug
70+
CXX: g++-9
71+
CC: gcc-9
72+
CXXFLAGS: -fext-numeric-literals
73+
steps:
74+
- uses: actions/checkout@v3
75+
- uses: actions/setup-node@v3
76+
with:
77+
node-version: "14"
78+
79+
- name: Test
80+
run: |
81+
npm ci
82+
./scripts/setup.sh --config local.env
83+
source local.env
84+
make ${BUILDTYPE}
85+
npm test
86+
87+
build:
88+
needs: [test, asan-build-test, g-build-test]
89+
runs-on: ${{ matrix.os.host }}
90+
strategy:
91+
matrix:
92+
os:
93+
- name: darwin
94+
architecture: x86-64
95+
host: macos-10.15
96+
97+
- name: linux
98+
architecture: x86-64
99+
host: ubuntu-20.04
100+
101+
steps:
102+
- uses: actions/checkout@v3
103+
- uses: actions/setup-node@v3
104+
with:
105+
node-version: "16"
106+
107+
- name: Build
108+
run: |
109+
./scripts/setup.sh --config local.env
110+
source local.env
111+
make release
112+
113+
- name: Prebuildify ${{ matrix.os.name }}-${{ matrix.os.architecture }}
114+
run: npm run prebuildify -- --platform=${{ matrix.os.name }} --arch=x64
115+
116+
# Upload the end-user binary artifact
117+
- uses: actions/upload-artifact@v3
118+
with:
119+
name: prebuilds
120+
path: prebuilds
121+
retention-days: 14

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ mason_packages
88
lib/binding
99
.toolchain
1010
.mason
11-
local.env
11+
local.env
12+
prebuilds
13+
*.tgz

.travis.yml

Lines changed: 0 additions & 166 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.7.2
2+
3+
- Removes `node-pre-gyp` in favor of `prebuildify` to package binaries. [#184](https://github.com/mapbox/node-fontnik/pull/184)
4+
15
# 0.7.1
26

37
- Fixes issue with `point-in-polygon` algorithm being used in `sdf-glyph-foundary`

DEV.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
### Tagging and publishing binaries via Travis
1+
### Tagging and publishing binaries via Github Actions
22

3-
On each commit that passes through Travis, the [`travis_publish.sh`](https://github.com/mapbox/node-fontnik/blob/master/deps/travis_publish.sh) script checks for the string `[publish binary]` in the commit message, and if present, runs `node-pre-gyp publish` to publish a binary.
3+
On each commit that passes through GitHub actions workflow, the binaries are generated for `linux-x64` and `darwin-x64`. These binaries can be downloaded when publishing the npm package.
44

5-
Running `npm publish` doesn't actually upload a binary anywhere, but instead just pushes up your local code with an updated version number in `package.json`. When your module is installed with `npm install`, `node-pre-gyp` will use this version number to search for a published binary, falling back to a source compile if no matching binary is found.
5+
Running `npm publish` uses the binaries present in the `prebuilds` directory. When the module is installed with `npm install`, a pre-built binary in the `prebuilds` directory is used if there's one that's suitable for the OS and architecture of the machine. Otherwise, the binary is built from the source when installing.
66

77
Typical workflow:
88

@@ -25,6 +25,11 @@ git push --tags
2525
# test published binary (should install from remote)
2626
npm install && npm test
2727
28+
# Make sure that the GHA workflow is successfull. Download the artifacts
29+
npm run download-binaries
30+
2831
# publish to npm
2932
npm publish
3033
```
34+
35+
> Note: gh CLI is required in order to download binaries from GH workflow runs. Follow the instruction in the [link](https://github.com/cli/cli#installation) to install the CLI. Run `gh auth login` and follow the instructions to authenticate before downloading binaries.

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ export WERROR ?= false
55

66
default: release
77

8-
./node_modules/.bin/node-pre-gyp:
8+
./node_modules/.bin/node-gyp:
99
# install deps but for now ignore our own install script
1010
# so that we can run it directly in either debug or release
1111
npm install --ignore-scripts
1212

13-
release: ./node_modules/.bin/node-pre-gyp
14-
V=1 ./node_modules/.bin/node-pre-gyp configure build --error_on_warnings=$(WERROR) --loglevel=error
13+
release: ./node_modules/.bin/node-gyp
14+
V=1 ./node_modules/.bin/node-gyp configure build --error_on_warnings=$(WERROR) --loglevel=error
1515
@echo "run 'make clean' for full rebuild"
1616

17-
debug: ./node_modules/.bin/node-pre-gyp
18-
V=1 ./node_modules/.bin/node-pre-gyp configure build --error_on_warnings=$(WERROR) --loglevel=error --debug
17+
debug: ./node_modules/.bin/node-gyp
18+
V=1 ./node_modules/.bin/node-gyp configure build --error_on_warnings=$(WERROR) --loglevel=error --debug
1919
@echo "run 'make clean' for full rebuild"
2020

2121
coverage:
@@ -45,9 +45,10 @@ distclean: clean
4545
rm -rf .mason
4646
rm -rf .toolchain
4747
rm -f local.env
48+
rm -rf prebuilds
4849

49-
xcode: ./node_modules/.bin/node-pre-gyp
50-
./node_modules/.bin/node-pre-gyp configure -- -f xcode
50+
xcode: ./node_modules/.bin/node-gyp
51+
./node_modules/.bin/node-gyp configure -- -f xcode
5152

5253
@# If you need more targets, e.g. to run other npm scripts, duplicate the last line and change NPM_ARGUMENT
5354
SCHEME_NAME="$(MODULE_NAME)" SCHEME_TYPE=library BLUEPRINT_NAME=$(MODULE_NAME) BUILDABLE_NAME=$(MODULE_NAME).node scripts/create_scheme.sh

binding.gyp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@
5353
]
5454
},
5555
{
56-
# module_name and module_path are both variables passed by node-pre-gyp from package.json
57-
'target_name': '<(module_name)', # sets the name of the binary file
58-
'product_dir': '<(module_path)', # controls where the node binary file gets copied to (./lib/binding/module.node)
56+
'target_name': 'fontnik', # sets the name of the binary file
57+
'product_dir': './lib/bindings', # controls where the node binary file gets copied to (./lib/binding/module.node)
5958
'type': 'loadable_module',
6059
'dependencies': [ 'action_before_build' ],
6160
# "make" only watches files specified here, and will sometimes cache these files after the first compile.

0 commit comments

Comments
 (0)