Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Use N-API prebuilds #106

Merged
merged 4 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 71 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: CI

on:
push:
branches: [ master ]
branches: [master]
tags:
- v*.*.*
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:
Expand All @@ -16,6 +16,8 @@ jobs:
CC: "clang"
CXX: "clang++"
npm_config_clang: "1"
# Needed until macos-11.0 hosted runners are available
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk"

strategy:
matrix:
Expand All @@ -32,47 +34,56 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- run: npm install
name: Setup environment

- run: npm test
name: Run tests (Windows/macOS)

- run: |
npm run prebuild-node
npm run prebuild-electron
name: Prebuild (x64)

- run: |
npm run prebuild-electron-arm64
npm run prebuild-electron-ia32
if: ${{ matrix.os == 'windows-latest' }}
name: Prebuild (Windows x86 + ARM64)

- run: |
mkdir -p prebuilds && chmod 777 prebuilds
docker build -t node-fs-admin/i386 docker/i386
docker run --rm -v ${PWD}:/project node-fs-admin/i386 /bin/bash -c "cd /project && npm run prebuild-electron-ia32 && rm -rf build"
docker build -t node-fs-admin/arm64-cross-compile docker/arm64-cross-compile
docker run --rm -v ${PWD}:/project node-fs-admin/arm64-cross-compile /bin/bash -c "cd /project && npm run prebuild-electron-arm64"
if: ${{ matrix.os == 'ubuntu-16.04' }}
name: Prebuild (Linux x86 + ARM64)

- run: |
ls prebuilds/
name: List prebuilds

- name: Upload prebuilds to GitHub
run: npm run upload
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
env:
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

# This step can be removed as soon as official Windows arm64 builds are published:
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
- run: |
$NodeVersion = (node --version) -replace '^.'
$NodeFallbackVersion = "15.8.0"
& .\script\download-node-lib-win-arm64.ps1 $NodeVersion $NodeFallbackVersion
if: ${{ matrix.os == 'windows-latest' }}
name: Install Windows arm64 node.lib

- run: npm install
name: Setup environment

- run: npm test
name: Run tests (Windows/macOS)

- run: npm run prebuild-napi-x64
name: Prebuild (x64)

- run: npm run prebuild-napi-arm64
name: Prebuild (arm64)
if: ${{ matrix.os != 'ubuntu-16.04' }}

- run: npm run prebuild-napi-ia32
if: ${{ matrix.os == 'windows-latest' }}
name: Prebuild (Windows x86)

- run: |
mkdir -p prebuilds && chmod 777 prebuilds
docker build -t node-fs-admin/i386 docker/i386
docker run --rm -v ${PWD}:/project node-fs-admin/i386 /bin/bash -c "cd /project && npm run prebuild-napi-ia32 && rm -rf build"
docker build -t node-fs-admin/arm64-cross-compile docker/arm64-cross-compile
docker run --rm -v ${PWD}:/project node-fs-admin/arm64-cross-compile /bin/bash -c "cd /project && npm run prebuild-napi-arm64"
if: ${{ matrix.os == 'ubuntu-16.04' }}
name: Prebuild (Linux x86 + ARM64)

- run: |
ls prebuilds/
name: List prebuilds

- name: Upload prebuilds to GitHub
run: npm run upload
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
env:
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Separate step for publishing to NPM so we're sure that generating + uploading prebuilds worked on all platforms
npm-publish:
Expand All @@ -82,20 +93,20 @@ jobs:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')

steps:
- uses: actions/checkout@v2
- name: Use Node.js 15
uses: actions/setup-node@v1
with:
node-version: 15.x
registry-url: 'https://registry.npmjs.org'

- run: sudo apt-get install libsecret-1-dev
name: Install additional dependencies

- run: npm install
name: Setup environment

- run: npm publish --access public
name: Upload to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- uses: actions/checkout@v2
- name: Use Node.js 15
uses: actions/setup-node@v1
with:
node-version: 15.x
registry-url: "https://registry.npmjs.org"

- run: sudo apt-get install libsecret-1-dev
name: Install additional dependencies

- run: npm install
name: Setup environment

- run: npm publish --access public
name: Upload to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
14 changes: 13 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@
'targets': [
{
'target_name': 'fs_admin',
'defines': [
"NAPI_VERSION=<(napi_build_version)",
],
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.7',
},
'msvs_settings': {
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
},
'sources': [
'src/main.cc',
],
'include_dirs': [
'<!(node -e "require(\'nan\')")'
'<!(node -p "require(\'node-addon-api\').include_dir")',
],
'conditions': [
['OS=="win"', {
Expand Down
Loading