Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add github actions for prebuilding #459

Merged
merged 6 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
59 changes: 59 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI
on:
pull_request:
push:

defaults:
run:
shell: bash

jobs:
Build:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- macos-latest
- windows-latest
node_version:
- 14
node_arch:
- x64
include:
- os: windows-latest
node_version: 14
node_arch: x86
# - os: macos-11.0
# node_version: 15
# node_arch: arm64
steps:
- uses: actions/checkout@v2

- name: Install Node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
architecture: ${{ matrix.node_arch }}

- name: Install Dependencies and Build
run: npm install

- name: Prebuild
run: npm run prebuild
env:
ARCH: ${{ matrix.node_arch }}

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
path: ./prebuilds

Skip:
if: contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- name: Skip CI 🚫
run: echo skip ci
71 changes: 3 additions & 68 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,100 +75,35 @@ jobs:

## PREBUILD STAGE

- stage: prebuild
os: linux
env: ARCHIVE_SUFFIX=-x64
node_js: "14"
script: script/ci/prebuild.sh

- stage: prebuild
os: linux
env: ALPINE_CHROOT=3.10 ARCHIVE_SUFFIX=-x64-musl
sudo: required
script: script/ci/prebuild.sh
script: npm run prebuild

- stage: prebuild
os: linux
node_js: "14"
env: ARCH=arm TRIPLE=arm-linux-gnueabihf GCC=8 ARCHIVE_SUFFIX=-armv7
addons: {apt: {packages: [gcc-8-arm-linux-gnueabihf, g++-8-arm-linux-gnueabihf]}}
script: script/ci/prebuild.sh
script: npm run prebuild

- stage: prebuild
os: linux
node_js: "14"
env: ARCH=arm64 TRIPLE=aarch64-linux-gnu GCC=8 ARCHIVE_SUFFIX=-armv8
addons: {apt: {packages: [gcc-8-aarch64-linux-gnu, g++-8-aarch64-linux-gnu]}}
script: script/ci/prebuild.sh

- stage: prebuild
os: osx
osx_image: xcode10
node_js: "14"
script: script/ci/prebuild.sh

- stage: prebuild
os: windows
node_js: "14"
# https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288
env: YARN_GPG=no ARCHIVE_SUFFIX=-x64
script: script/ci/prebuild.sh

- stage: prebuild
os: windows
node_js: "14/x86"
# https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288
env: YARN_GPG=no ARCHIVE_SUFFIX=-x86
script: script/ci/prebuild.sh

## PUBLISH STAGE

- stage: publish
os: linux
node_js: "14"
env: IGNORE_SCRIPTS=true
script: script/ci/package.sh
script: npm run prebuild

fast_finish: true

stages:
- name: test
- name: prebuild
if: tag IS present
- name: publish
if: tag IS present

install:
- travis_retry script/ci/install.sh

script:
- travis_retry script/ci/test.sh

deploy:
# Deploy prebuilds to Github releases.
- provider: releases
draft: false
file: "${TRAVIS_TAG:-latest}-${TRAVIS_OS_NAME}${ARCHIVE_SUFFIX}.tar.gz"
skip_cleanup: true
on:
tags: true
condition: "$TRAVIS_BUILD_STAGE_NAME = Prebuild"
api_key:
# Github API token for @zeromqjs-integration
secure: CvjUt3eRB1J6H9vxx/WrI4jOMX+jjgUSuC3z0r1tEfTKsrkt0Eoovn22tWP45aYeZd0clbV0aIhi3jvkZVAXvQ6y+WPdY9ZsQ1AJtZkVyT3qOdxeybcM0x5NY0q6dnROOwJ8O8Y6FeOrNdEuSImrCrCcPaPv9ZIM9Dv8jto5d5VypFtF5GaZ0nZPRuUgKVXDEKcHVZPgDhgHmjPzVAO0XXdHbgQtUlGYvhQmNhSE5njGFg1lm4+CWkDdpWAiehv0kwtCSx3pn3WtfO4Romt9fk662ykRYDSve0TryR2HBvISqmM64E2NU1VjqGy0nSdyVD7s9gV2hE+FG/N3/n4lYUH3UtaIwjqNmlgQpl/mDz/y5W0nTscigWkzPuk0HqiEHQ0Wk6jZLvw3cUD5YXBgESg0nbBIt+TIaCp2/Z+vENtD3blaXH0n4vXJhRDAlbQ/E7CvIWOUTaSuXfK3ugGoifzc78MyAK0TdYCX+EJoIWe5l+o8TExrWdSp4485dcsex1vOo5Wd7bPIvfsDzfNjmraanoFxUCfU+lrxuQqPN4Ot/MoltThhMJwTZJCdnZsZPYR3oznI7Dn5gLyijpNwLWTlHDsSTcZuronE8WEFHUiNwsVnt29tvp6m6OBin6gZUCXoR78c0DQoyTpS8Nc2zKbK1ps6pelKhs39K1n+d+U=

# Deploy package including all generated prebuilds to NPM.
- provider: npm
email: rolftimmermans+zeromqjs@voormedia.com
skip_cleanup: true
on:
tags: true
condition: "$TRAVIS_BUILD_STAGE_NAME = Publish"
api_key:
# NPM API token for @zeromqjs-integration
secure: 2dWaYpf8DDmfD0zoDLs2QFhE+vNT9vq2UOb6A+SHnsqkxfTh3xkkT0EyKEjAF7vQ03QKI6cYMcz9YVr7pwfoN1xWS1JA78YcZ9aG2+De1HW2tbi0SsDJgMzMv+OejloH9T0Mzth5k45ehRkXjijkBnTGT1j1AdXvTg0+MAOxEO0Q30aMUMBQ4y+0JB9S9UCE6Cs/BWt0mdoKXsb4pL+gJBSbE4wzrkthIkvG8Am6EybztLOjyGlWdvtDQeNe0JwMjeHMlmp/k4auXS+3x+JBcjCqxXxGQnDUHaZ31nFGVx6ns9rmsupe9FzWqOBYBwWRO0G0+Ku17gjluQLvqalib9SEcZiLv+nCpWlHoQNBuAoVz+CoCkfWCp6OUkJ5NpAkQRDSF/7s4A1gzzT7Ne+Ux670PhkvHLJpH4Pt08QqtRsSdjuj566DbYqdEmdW8SwOnRzigs4eVY6m+O6PDD6j4vBzeoE0zIDsCfCEsk6CaErdMQhQOb+wZTL1DRz49YgwUTZym9ekgf/hNrDqMkVuM1RT8L2CUqBHhmqAq6yJ4c11C1O2DEWC4MgIqw7/sfrsFtZlauaU/NyUDf2q6NXnPLISp8M+06ES+eNynyM1w8F+6bBebAe6GN4+DAUlt+VKtREIzxqKRG/2PZ7aYYbt2nlmTa4e/Lp7/MLqoZEOvPw=

env:
global:
# GITHUB_TOKEN=<Github API token for @zeromqjs-integration>
secure: x3reA0+odqmuxZbUfQCbT/bXI4pBC2VDidUyt2kn0BFmEWI5J8dXV0rXM0Ai/iCh5ESm6mIbzAjw1mOBgke6OET9gbZbAdMMqX30abAEBsvBu+z/t/cpXmTEOPCTjBIvJhmJxOZxjyR3iG+lI9L8DdheWt0sS/ucD3w1Qd0eoD8wo2+ynWxdeeC0ZZLdO94UM/1QJMDqsShLQBu9tvhDWgmxjzyENC6vhXKuesLV4lwqZTCw4Kqp4SeWml5R1sY7PZWCj0EoxIskSK8KDCHHrvNWcXCB5gTIbmpcpnHZyci6gi3Tl5FhRVXUrYwfm87hPrqrqBOMeCcEmrEHz7AfwgrPpunneq8cCd4JJp9LHQMGurUy5eX9ArJFGiLS1PkygOu6N7Ob3nzUxIQp5psO9u0aMLWOAWmlgFLi5VRdDGiKIBIdy0uwKB1Cxk1R4ULjgBvAVhCmikuOd48H4a6cUmblOFoapWeVYX/p34L62sJEXLSYUENiCJ3hFV3Yq3YiozkcyGAbnmrqfXPT1fSJa21AMyn0D2x+I4/BDvMGOnoX9yVxJPqwNP4C7adevsYod4Z6x6dhhHfYFyP8kKMLzydXdK9tkPi20VNvpQYHBoQCRKO4Rk+VDzBnhqSowYJqiOu2Wp6v+MaaJhmWMWOZKC/9hww7PA9DMIULQmXT3Do=
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'zmq_shared%': 'false',
'zmq_draft%': 'false',
'zmq_no_sync_resolve%': 'false',
'sanitizers%': 'false',
},

'targets': [
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
"install": "node-gyp-build",
"ci:compile": "tsc --project tsconfig-build.json && node script/ci/downlevel-dts.js",
"ci:doc": "typedoc --out docs --name zeromq.js --excludeProtected --excludePrivate --excludeNotExported --excludeExternals --externalPattern 'src/+(draft|native|compat).ts' --tsconfig tsconfig-build.json --mode file",
"ci:prebuild": "npm run prebuildify",
"prebuildify": "prebuildify --napi -t 12.0.0 -t electron@9.4.4 --strip",
"prebuild": "ts-node -P ./tsconfig.json ./script/prebuild.ts",
"dev:build": "rm -f vendor/* && touch vendor/.gitkeep && cp node_modules/node-addon-api/{*.h,LICENSE.md} vendor && prebuildify --napi --build-from-source --debug",
"dev:test": "tsc --project tsconfig-build.json && node script/ci/downlevel-dts.js && mocha && script/format.sh && rm -f tmp/*",
"dev:bench": "node --expose-gc test/bench"
Expand Down
6 changes: 6 additions & 0 deletions script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ if [ -n "${WINDIR}" ]; then
# Working directory is NAPI temporary build directory.
PATH_PREFIX="${PWD}/libzmq"
ARTIFACT="${PATH_PREFIX}/lib/libzmq.lib"

# Handle x86 or x64 build
if [ -z "${ARCH}" ]; then
ARCH="x64"
fi
BUILD_OPTIONS="-DCMAKE_GENERATOR_PLATFORM=${ARCH} ${BUILD_OPTIONS}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be enough

else
# Working directory is project root.
PATH_PREFIX="${PWD}/build/libzmq"
Expand Down
30 changes: 0 additions & 30 deletions script/ci/prebuild.sh

This file was deleted.

56 changes: 56 additions & 0 deletions script/prebuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* eslint-disable @typescript-eslint/camelcase */

import {spawnSync} from "child_process"

main().catch(e => {
throw e
})

async function main() {
console.log("Building distribution binary...")

const prebuildArch = getNodearch(process.env.ARCH)

if (process.env.TRIPLE) {
const TRIPLE = process.env.TRIPLE

const GCC = process.env.GCC
process.env.CC = `${TRIPLE}-gcc-${GCC}`
process.env.CXX = `${TRIPLE}-g++-${GCC}`

const STRIP = `${TRIPLE}-strip`
process.env.PREBUILD_STRIP_BIN = STRIP

process.env.npm_config_arch = prebuildArch
process.env.npm_config_target_arch = prebuildArch
process.env.PREBUILD_arch = prebuildArch

process.env.ZMQ_BUILD_OPTIONS = `--host=${TRIPLE}`
}

let prebuildScript = `prebuildify --napi --arch=${prebuildArch} -t 12.0.0 -t electron@9.4.4 --strip`

if (process.platform == "linux") {
prebuildScript = `${prebuildScript} --tag-libc`
}
if (process.env.ALPINE_CHROOT) {
prebuildScript = `/alpine/enter-chroot ${prebuildScript}`
}

spawnSync(prebuildScript, {
shell: true,
stdio: "inherit",
encoding: "utf8",
})
}

function getNodearch(arch: string | undefined): string {
if (!arch) {
return process.arch
}
if (arch === "x86") {
return "ia32"
} else {
return arch
}
}