Adds prebuilt binary builder setup (#366)

* Prebuilt setup (#3)

* Adds prebuild

* Adds prebuild

* fix branch name

* adds prebuild upload

* fix windows build and performance bump for prebuild

* remove pre-release

* adds updated

* edited

* test

* move to all platforms

* change to master

* change to release event

* install qode explicitly

* Adds npm skip build flag

* Adds build triggers

* Repo dispatchs

* change to all events

* Update prebuild.yml

* test

* fix prevuild

* test

* test

* change to master release

* change to nodegui

* change the master tag check

* adds conditional before overwriting NAPI_VERSION
This commit is contained in:
Atul R 2020-01-24 19:11:01 +01:00 committed by GitHub
parent 625f91cc7e
commit a84bc69a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 972 additions and 94 deletions

View File

@ -19,21 +19,27 @@ jobs:
- name: Build nodegui
run: npx tsc
- name: Archive using npm pack
run: npm --no-git-tag-version version 1.0.0-master && npm pack
run: npm --no-git-tag-version version 0.0.0-latest-master && npm pack
- uses: actions/upload-artifact@v1
with:
name: latest-release
path: nodegui-nodegui-1.0.0-master.tgz
path: nodegui-nodegui-0.0.0-latest-master.tgz
- uses: nodegui/create-release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
code: latest-master
code: v0.0.0-latest-master
name: Latest Master Release
body: >
Latest auto release corresponding to commit ${{github.sha}} 🔥.
To install do:
`npm install https://github.com/nodegui/nodegui/releases/download/latest-master/nodegui-master.tgz`
`npm install https://github.com/nodegui/nodegui/releases/download/v0.0.0-latest-master/nodegui-master.tgz`
assets: >
nodegui-nodegui-1.0.0-master.tgz:nodegui-master.tgz:application/tar+gzip
nodegui-nodegui-0.0.0-latest-master.tgz:nodegui-master.tgz:application/tar+gzip
recreate: true
prerelease: true
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: nodegui/nodegui
event-type: on-demand-build
client-payload: '{"ref": "${{ github.ref }}","tag": "v0.0.0-latest-master"}'

35
.github/workflows/prebuild.yml vendored Normal file
View File

@ -0,0 +1,35 @@
on:
repository_dispatch:
types: [on-demand-build]
release:
types: [published, created, prereleased]
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- uses: actions/setup-node@master
with:
node-version: '13.x'
- name: Install deps
run: npm install
env:
SKIP_BUILD: 1
- name: Change version if master
if: contains(github.event.client_payload.tag, '0.0.0-latest-master')
run: npm --no-git-tag-version version 0.0.0-latest-master
- name: Prebuild binary
run: npm run prebuild:build
- name: Release
uses: softprops/action-gh-release@master
with:
files: prebuilds/@nodegui/*.tar.gz
tag_name: ${{ github.event.release.tag_name || github.event.client_payload.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ dist
coverage
.DS_Store
/.idea/
/prebuilds

View File

@ -167,7 +167,7 @@ target_link_libraries(${CORE_WIDGETS_ADDON} PRIVATE
if (WIN32)
target_compile_definitions(${CORE_WIDGETS_ADDON} PRIVATE
ENABLE_DLL_EXPORT
ENABLE_DLL_EXPORT=1
)
target_compile_options(${CORE_WIDGETS_ADDON} PRIVATE "/MP4")

View File

@ -11,6 +11,13 @@ function(AddCommonConfig addonName)
cxx_variadic_templates
cxx_variable_templates
)
if(napi_build_version)
target_compile_definitions(${addonName} PRIVATE
NAPI_VERSION=${napi_build_version}
)
endif()
if (WIN32)
target_compile_definitions(${addonName} PRIVATE
ENUM_BITFIELDS_NOT_SUPPORTED

889
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@nodegui/nodegui",
"version": "0.12.1",
"version": "0.13.0",
"description": "A cross platform library to build native desktop apps.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
@ -10,8 +10,10 @@
"scripts": {
"dev": "npm run build && qode dist/demo.js",
"build": "tsc && npm run build:addon",
"postinstall": "npm run build:addon",
"postinstall": "cross-env node ./scripts/skip.js || npm run prebuild:install || npm run build:addon",
"build:addon": "cross-env CMAKE_BUILD_PARALLEL_LEVEL=8 cmake-js compile",
"prebuild:build": "prebuild --all --backend=cmake-js --runtime=napi",
"prebuild:install": "prebuild-install --backend=cmake-js --runtime=napi --verbose",
"test": "qode ./node_modules/jest/bin/jest -i",
"lint:cpp": "clang-format -i --glob=src/cpp/**/*.[h,c]*",
"lint:ts": "tsc --noEmit && cross-env eslint './src/**/*.{ts,tsx,js,jsx}' --fix",
@ -23,7 +25,8 @@
"cross-env": "^6.0.0",
"cuid": "^2.1.6",
"node-addon-api": "^2.0.0",
"postcss-nodegui-autoprefixer": "0.0.7"
"postcss-nodegui-autoprefixer": "0.0.7",
"prebuild-install": "^5.3.3"
},
"devDependencies": {
"@types/bindings": "^1.3.0",
@ -37,15 +40,37 @@
"eslint-plugin-prettier": "^3.1.1",
"husky": "^4.0.10",
"jest": "^24.9.0",
"prebuild": "^9.1.1",
"prettier": "^1.18.2",
"ts-jest": "^24.1.0",
"typedoc": "^0.16.7",
"typedoc-plugin-markdown": "^2.2.14",
"typescript": "^3.7.3"
},
"binary": {
"napi_versions": [
3
]
},
"husky": {
"hooks": {
"pre-push": "npm run build && npm run lint:ts && npm run lint:cpp && npm run test"
}
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/nodegui/nodegui.git"
},
"keywords": [
"nodegui",
"gui",
"qt",
"nodejs",
"css",
"desktop"
],
"bugs": {
"url": "https://github.com/nodegui/nodegui/issues"
},
"homepage": "https://github.com/nodegui/nodegui#readme"
}

5
scripts/skip.js Normal file
View File

@ -0,0 +1,5 @@
if (process.env.SKIP_BUILD) {
process.exit(0);
} else {
process.exit(1);
}

View File

@ -1,81 +1,7 @@
import {
QWidget,
QMainWindow,
FlexLayout,
QTreeWidget,
QMenuBar,
QApplication,
QMenu,
QCursor,
QPushButton,
} from './index';
import { QPoint } from './lib/QtCore/QPoint';
import { QAction } from './lib/QtWidgets/QAction';
import { QMainWindow } from './index';
const win = new QMainWindow();
const center = new QWidget();
const layout = new FlexLayout();
center.setLayout(layout);
win.setCentralWidget(center);
const tree = new QTreeWidget();
tree.hide();
tree.setColumnCount(2);
tree.setHeaderLabels(['Properties', 'Value']);
center.layout?.addWidget(tree);
const menubar = new QMenuBar();
win.setMenuBar(menubar);
const fm = menubar.addMenu('&File');
const qaction = fm.addAction('&Quit');
fm.addSeparator();
const showTree = fm.addAction('&ShowTree');
const hideTree = fm.addAction('&HideTree');
const menu = new QMenu();
const sh = menu.addAction('SayHello');
// Button row
const buttonRow = new QWidget();
const buttonRowLayout = new FlexLayout();
buttonRow.setLayout(buttonRowLayout);
buttonRow.setObjectName('buttonRow');
// Buttons
const button = new QPushButton();
button.setText('click me');
button.setObjectName('clickme');
buttonRowLayout.addWidget(button);
layout.addWidget(buttonRow);
qaction.addEventListener('triggered', () => {
const app = QApplication.instance();
app.exit(0);
});
showTree.addEventListener('triggered', () => {
tree.show();
});
hideTree.addEventListener('triggered', () => {
tree.hide();
});
button.addEventListener('clicked', () => {
const { x, y } = new QCursor().pos();
menu.exec(new QPoint(x, y), new QAction());
});
sh.addEventListener('triggered', () => {
console.log('Hello!');
});
menubar.addSeparator();
menubar.addMenu('Hello');
win.show();
(global as any).win = win;
setInterval(() => null, 1000);