Skip to content

Commit

Permalink
feat(*): use pre-built binaries (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
derevnjuk committed Aug 27, 2023
1 parent 21d25a3 commit 764436c
Show file tree
Hide file tree
Showing 9 changed files with 4,318 additions and 4,318 deletions.
299 changes: 283 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,307 @@
name: Automated deploy

on:
push:
tags:
- 'v*'
workflow_dispatch:
release:
types: [created]

env:
VERSION: ${{ github.event.release.tag_name }}
TARGET_REF: ${{ github.event.release.target_commitish }}

jobs:
build_x86_64:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-11, windows-2019 ]
node: [ 14, 16, 18, 19, 20 ]
arch: [ x64 ]
include:
- os: windows-2019
node: 16
arch: ia32
- os: windows-2019
node: 18
arch: ia32
- os: windows-2019
node: 19
arch: ia32
- os: windows-2019
node: 20
arch: ia32
exclude:
- os: windows-2019
node: 14
arch: x64
env:
npm_config_msvs_version: 2019
npm_config_python: python3.10
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
architecture: ${{ matrix.arch == 'ia32' && 'x86' || 'x64' }}

- name: Install dependencies
run: npm ci --ignore-scripts

- name: Prebuild package
run: npx @mapbox/node-pre-gyp --target_arch=${{ matrix.arch }} configure build package

- name: Upload binaries to GitHub Release
run: npx node-pre-gyp-github publish
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
build_musl_x86_64:
runs-on: ubuntu-20.04
container:
image: node:${{ matrix.node }}-alpine
strategy:
fail-fast: false
matrix:
node: [ 14, 16, 18, 19, 20 ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}

- name: Setup env with Node v${{ matrix.node }}
run: |
apk add --update
apk add --no-cache ca-certificates git curl build-base python3 g++ make
- name: Install dependencies
run: npm ci --ignore-scripts

- name: Prebuild package
run: npx @mapbox/node-pre-gyp configure build package

- name: Upload binaries to GitHub Release
run: |
CC=x86_64-linux-musl-gcc \
CXX=x86_64-linux-musl-g++ \
npx node-pre-gyp-github publish
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
build_aarch64:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
node: [ 14, 16, 18, 19, 20 ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}

- name: Install cross-compilation tools
run: |
sudo apt-get update -yq \
&& sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -yq \
&& sudo apt-get clean \
&& sudo rm -rf /var/lib/apt/lists/*
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm ci --ignore-scripts

- name: Prebuild package
run: |
CC=aarch64-linux-gnu-gcc \
CXX=aarch64-linux-gnu-g++ \
npx @mapbox/node-pre-gyp --target_arch=arm64 configure build package
- name: Upload binaries to GitHub Release
run: npx node-pre-gyp-github publish
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
build_darwin_aarch64:
runs-on: macos-11
strategy:
fail-fast: false
matrix:
node: [ 14, 16, 18, 19, 20 ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm ci --ignore-scripts

- name: Prebuild package
run: |
CFLAGS="-target arm64-apple-macos11 -arch arm64" \
npx @mapbox/node-pre-gyp --target_arch=arm64 configure build package
- name: Upload binaries to GitHub Release
run: npx node-pre-gyp-github publish
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
build_musl_aarch64:
runs-on: ubuntu-20.04
container:
image: node:${{ matrix.node }}-alpine
strategy:
fail-fast: false
matrix:
node: [ 14, 16, 18, 19, 20 ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}

- name: Setup env with Node v${{ matrix.node }}
run: |
apk add --update
apk add --no-cache ca-certificates git curl build-base python3 g++ make
- name: Setup musl cross compiler
run: |
curl -OL https://musl.cc/aarch64-linux-musl-cross.tgz
tar -xzvf aarch64-linux-musl-cross.tgz
$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc --version
- name: Install dependencies
run: npm ci --ignore-scripts

- name: Prebuild package
run: |
CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc \
CXX=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ \
npx @mapbox/node-pre-gyp --target_arch=arm64 configure build package
- name: Upload binaries to GitHub Release
run: npx node-pre-gyp-github publish
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
build_arm:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
node: [ 14, 16, 18, 19, 20 ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}

- name: Install cross-compilation tools
run: |
sudo apt-get update -yq \
&& sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -yq \
&& sudo apt-get clean \
&& sudo rm -rf /var/lib/apt/lists/*
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm ci --ignore-scripts

- name: Prebuild package
run: |
CC=arm-linux-gnueabihf-gcc \
CXX=arm-linux-gnueabihf-g++ \
npx @mapbox/node-pre-gyp --target_arch=arm configure build package
- name: Upload binaries to GitHub Release
run: npx node-pre-gyp-github publish
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
build_musl_arm:
runs-on: ubuntu-20.04
container:
image: node:${{ matrix.node }}-alpine
strategy:
fail-fast: false
matrix:
node: [ 14, 16, 18, 19, 20 ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}

- name: Setup env with Node v${{ matrix.node }}
run: |
apk add --update
apk add --no-cache ca-certificates git curl build-base python3 g++ make
- name: Setup musl cross compiler
run: |
curl -OL https://musl.cc/arm-linux-musleabihf-cross.tgz
tar -xzvf arm-linux-musleabihf-cross.tgz
$(pwd)/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-gcc --version
- name: Install dependencies
run: npm ci --ignore-scripts

- name: Prebuild package
run: |
CC=$(pwd)/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-gcc \
CXX=$(pwd)/arm-linux-musleabihf-cross/bin/arm-linux-musleabihf-g++ \
npx @mapbox/node-pre-gyp --target_arch=arm configure build package
- name: Upload binaries to GitHub Release
run: npx node-pre-gyp-github publish
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
deploy:
needs:
- build_x86_64
- build_musl_x86_64
- build_aarch64
- build_darwin_aarch64
- build_musl_aarch64
- build_arm
- build_musl_arm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ env.TARGET_REF }}
token: ${{ secrets.GPR_TOKEN }}

- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 12
node-version: 18
registry-url: 'https://registry.npmjs.org'

- run: echo "VERSION=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV

- run: npm ci -q
- run: npm version --no-git-tag-version "$VERSION"
- name: Install dependencies
run: npm ci --ignore-scripts

- run: npm publish
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 12
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: '@NeuraLegion'

- run: npm publish
- name: Publish to GPR
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GPR_TOKEN }}
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
token: ${{ secrets.GPR_TOKEN }}
- uses: actions/setup-node@v1

- uses: actions/setup-node@v3
with:
node-version: 12
node-version: 18

- run: npm ci -q
- run: npm ci --ignore-scripts
- run: npm run semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
syntax: glob
.idea
build
lib
node_modules/
example/*.log
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.github
build
lib
node_modules
.releaserc
.gitignore
22 changes: 18 additions & 4 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
[
"@semantic-release/commit-analyzer",
{
"releaseRules": [
{ "type": "docs", "scope": "readme", "release": "patch" }
],
"parserOpts": {
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
}
Expand All @@ -29,6 +26,19 @@
"npmPublish": false
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "npm version --no-git-tag-version --allow-same-version ${nextRelease.version}"
}
],
[
"@semantic-release/git",
{
"assets": ["package*.json"],
"message": "chore(release): cut the ${nextRelease.version} release [skip ci]"
}
],
[
"@semantic-release/github",
{
Expand All @@ -40,6 +50,10 @@
}
]
],
"branch": "master",
"branches": [
{
"name": "master"
}
],
"ci": true
}
Loading

0 comments on commit 764436c

Please sign in to comment.