Prebuild Node.js modules; set up auto CLI and Node.js building
This commit is contained in:
parent
8e70199c15
commit
d581c9f159
|
@ -0,0 +1,49 @@
|
||||||
|
name: Build and upload CLI
|
||||||
|
|
||||||
|
on:
|
||||||
|
create:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cli:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
ARCH: linux-x86_64
|
||||||
|
MIME: application/octet-stream
|
||||||
|
EXT: ''
|
||||||
|
- os: windows-latest
|
||||||
|
ARCH: windows-x86_64
|
||||||
|
MIME: application/vnd.microsoft.portable-executable
|
||||||
|
EXT: '.exe'
|
||||||
|
- os: macos-latest
|
||||||
|
ARCH: macos-x86_64
|
||||||
|
MIME: application/octet-stream
|
||||||
|
EXT: ''
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Get version
|
||||||
|
id: version
|
||||||
|
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
|
||||||
|
- name: Get file name
|
||||||
|
id: file
|
||||||
|
run: echo ::set-output name=FILE::${{ steps.version.outputs.VERSION }}-${{ matrix.ARCH }}${{ matrix.EXT }}
|
||||||
|
- name: Set up Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
profile: minimal
|
||||||
|
default: true
|
||||||
|
- name: Build CLI
|
||||||
|
run: cargo build --release
|
||||||
|
- uses: chrislennon/action-aws-cli@v1.1
|
||||||
|
- name: Upload to S3
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_REGION: us-west-2
|
||||||
|
run: aws s3 cp ./nodejs/native/index.node s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/${{ steps.file.outputs.FILE }} --content-type ${{ matrix.MIME }}
|
|
@ -0,0 +1,52 @@
|
||||||
|
name: Build and upload Node.js native module
|
||||||
|
|
||||||
|
on:
|
||||||
|
create:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
nodejs:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
# Use windows-2016 as windows-2019 has LNK1181 error when building Neon module.
|
||||||
|
os: [ubuntu-latest, windows-2016, macos-latest]
|
||||||
|
node: [8, 9, 10, 11, 12, 13]
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
ARCH: linux-x86_64
|
||||||
|
- os: windows-latest
|
||||||
|
ARCH: windows-x86_64
|
||||||
|
- os: macos-latest
|
||||||
|
ARCH: macos-x86_64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Get version
|
||||||
|
id: version
|
||||||
|
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
|
||||||
|
- name: Get file name
|
||||||
|
id: file
|
||||||
|
run: echo ::set-output name=FILE::${{ steps.version.outputs.VERSION }}-${{ matrix.ARCH }}-node${{ matrix.node }}.node
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@master
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node }}.x
|
||||||
|
- name: Set up Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
profile: minimal
|
||||||
|
default: true
|
||||||
|
- name: Build native module
|
||||||
|
working-directory: ./nodejs
|
||||||
|
run: |
|
||||||
|
npm install -g neon-cli
|
||||||
|
neon build --release
|
||||||
|
- uses: chrislennon/action-aws-cli@v1.1
|
||||||
|
- name: Upload to S3
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_REGION: us-west-2
|
||||||
|
run: aws s3 cp ./nodejs/native/index.node s3://${{ secrets.AWS_S3_BUCKET }}/hyperbuild/bin/${{ steps.file.outputs.FILE }}
|
|
@ -17,6 +17,14 @@ Available as:
|
||||||
|
|
||||||
### CLI
|
### CLI
|
||||||
|
|
||||||
|
##### Get
|
||||||
|
|
||||||
|
[Windows](https://wilsonl.in/hyperbuild/bin/0.0.4-windows-x86_64.exe) |
|
||||||
|
[macOS](https://wilsonl.in/hyperbuild/bin/0.0.4-macos-x86_64) |
|
||||||
|
[Linux](https://wilsonl.in/hyperbuild/bin/0.0.4-linux-x86_64)
|
||||||
|
|
||||||
|
##### Use
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hyperbuild --src /path/to/src.html --out /path/to/output.min.html
|
hyperbuild --src /path/to/src.html --out /path/to/output.min.html
|
||||||
```
|
```
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const request = require('request');
|
||||||
|
|
||||||
|
const binaryPath = path.join(__dirname, "native", "index.node");
|
||||||
|
const binaryName = [
|
||||||
|
require('./package').version,
|
||||||
|
'-',
|
||||||
|
[process.platform, {
|
||||||
|
darwin: 'macos',
|
||||||
|
linux: 'linux',
|
||||||
|
win32: 'windows',
|
||||||
|
}],
|
||||||
|
'-',
|
||||||
|
[process.arch, {
|
||||||
|
x64: 'x86_64',
|
||||||
|
}],
|
||||||
|
'-node',
|
||||||
|
[process.versions.modules, {
|
||||||
|
// Sourced from https://nodejs.org/en/download/releases/.
|
||||||
|
57: 8,
|
||||||
|
59: 9,
|
||||||
|
64: 10,
|
||||||
|
67: 11,
|
||||||
|
72: 12,
|
||||||
|
79: 13,
|
||||||
|
}],
|
||||||
|
'.node',
|
||||||
|
].map(p => typeof p == 'string'
|
||||||
|
? p
|
||||||
|
: p[1][p[0]]
|
||||||
|
).join('');
|
||||||
|
const binaryUrl = `https://wilsonl.in/hyperbuild/bin/${binaryName}`;
|
||||||
|
|
||||||
|
console.log(`Fetching ${binaryUrl}...`);
|
||||||
|
request(binaryUrl)
|
||||||
|
.on('response', res => {
|
||||||
|
if (res.statusCode !== 200) {
|
||||||
|
console.error(`Failed to download prebuilt native module with status ${res.statusCode}, will build from source`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on('error', err => {
|
||||||
|
console.error(err);
|
||||||
|
console.error(`Could not download prebuilt native module, building from source...`);
|
||||||
|
process.exit(1);
|
||||||
|
})
|
||||||
|
.pipe(fs.createWriteStream(binaryPath));
|
|
@ -9,7 +9,7 @@ exclude = ["artifacts.json", "index.node"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "hyperbuild"
|
name = "hyperbuild_nodejs_lib"
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/wilsonzlin/hyperbuild.git"
|
"url": "git+https://github.com/wilsonzlin/hyperbuild.git"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8 <=13"
|
||||||
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"email": "npm@wilsonl.in",
|
"email": "npm@wilsonl.in",
|
||||||
"name": "Wilson Lin",
|
"name": "Wilson Lin",
|
||||||
|
@ -18,10 +21,11 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/wilsonzlin/hyperbuild#readme",
|
"homepage": "https://github.com/wilsonzlin/hyperbuild#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"neon-cli": "^0.3.3"
|
"neon-cli": "^0.3.3",
|
||||||
|
"request": "^2.88.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "neon build --release",
|
"install": "node install.js || neon build --release",
|
||||||
"prepack": "cp ../README.md .",
|
"prepack": "cp ../README.md .",
|
||||||
"postpack": "rm README.md"
|
"postpack": "rm README.md"
|
||||||
},
|
},
|
||||||
|
|
4
version
4
version
|
@ -18,3 +18,7 @@ for (const f of ["README.md", "nodejs/native/Cargo.toml"]) {
|
||||||
for (const f of ["nodejs/package.json"]) {
|
for (const f of ["nodejs/package.json"]) {
|
||||||
replaceInFile(f, /^(\s*)"version": "\d+\.\d+\.\d+",\s*$/m, `$1"version": "${NEW_VERSION}",`);
|
replaceInFile(f, /^(\s*)"version": "\d+\.\d+\.\d+",\s*$/m, `$1"version": "${NEW_VERSION}",`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const f of ["README.md"]) {
|
||||||
|
replaceInFile(f, /(wilsonl\.in\/hyperbuild\/bin\/)\d+\.\d+\.\d+/g, `$1${NEW_VERSION}`);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue