Skip to content

Commit 1a4f336

Browse files
committed
build package
1 parent 6ae43b0 commit 1a4f336

File tree

6 files changed

+100
-79
lines changed

6 files changed

+100
-79
lines changed

.github/buid.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,62 @@ on:
66
- master
77
tags:
88
- "*"
9+
env:
10+
FORCE_COLOR: 1
11+
jos:
12+
build:
13+
run-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
host: [x64]
18+
target: [x64]
19+
node: [18]
20+
include:
21+
- os: windows-latest
22+
host: x86
23+
target: x86
24+
node: 18
25+
- os: macos-m1
26+
host: arm64
27+
target: arm64
28+
node: 18
29+
name: os=${{ matrix.os }} host=${{ matrix.host }}, target=${{ matrix.target }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: ${{ matrix.node }}
35+
architecture: ${{ matrix.host }}
36+
37+
- name: add setuptools for python 3.12
38+
if: matrix.os != 'macos-m1'
39+
run: pip install setuptools
40+
41+
- name: Add msbuild to PATH
42+
uses: microsoft/setup-msbuild@v1.3
43+
if: contains(matrix.os, 'windows')
44+
with:
45+
msbuild-architecture: ${{ matrix.target }}
46+
47+
- name: Install dependencies
48+
run: npm install --build-from-source
49+
50+
- name: Build
51+
run: npm run build
52+
53+
- name: upload binaries to artifacts
54+
uses: actions/upload-artifact@v3
55+
with:
56+
name: prebuilt-binaries
57+
path: prebuilt/*
58+
retention-days: 7
59+
60+
- name: upload binaries to github release
61+
uses: actions/upload-release-asset@v1
62+
with:
63+
upload_url: ${{ github.event.release.upload_url }}
64+
asset_path: prebuilt/*
65+
asset_name: ${{ github.event.release.tag_name }}-${{ matrix.os }}-${{ matrix.host }}-${{ matrix.target }}.zip
66+
asset_content_type: application/zip
67+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build/
2-
node_modules/
2+
node_modules/
3+
lib
4+
*.tgz

binding.gyp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"targets": [
33
{
4-
"target_name": "robotjs",
4+
"target_name": "robotjs_addon",
55
"include_dirs": [],
66
"dependencies": [
77
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api"
@@ -73,6 +73,21 @@
7373
"src/snprintf.c",
7474
"src/MMBitmap.c"
7575
]
76+
},
77+
{
78+
"target_name": "action_after_build",
79+
"type": "none",
80+
"dependencies": [
81+
"robotjs_addon"
82+
],
83+
"copies": [
84+
{
85+
"files": [
86+
"<(PRODUCT_DIR)/<(module_name).node"
87+
],
88+
"destination": "<(module_path)"
89+
}
90+
]
7691
}
7792
]
7893
}

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
var robotjs = require("./build/Release/robotjs.node");
1+
var binary = require("@mapbox/node-pre-gyp");
2+
var path = require("path");
3+
var binding_path = binary.find(path.resolve(path.join(__dirname, "./package.json")));
4+
console.log("binding_path", binding_path);
5+
var binding = require(binding_path);
26

3-
module.exports = robotjs;
7+
module.exports = binding;

0 commit comments

Comments
 (0)