From 20de964f53c3a85969c89398915a69bf1cb6218c Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Wed, 14 Jun 2023 22:42:37 +0530 Subject: [PATCH] rebuild node-pty on chroot for linux arm builds add linux armhf builds --- .github/workflows/nodejs.yml | 68 ++++++++++++++++++++++++++++++++++ electron-builder-linux-ci.json | 6 +++ electron-builder.json | 31 ++-------------- package.json | 4 +- 4 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 electron-builder-linux-ci.json diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index aae4d24cab57..b8d8dfc903ca 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -97,3 +97,71 @@ jobs: with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }} + + build-linux-arm: + runs-on: ubuntu-20.04 + strategy: + matrix: + include: + - name: armv7l + cpu: cortex-a8 + image: raspios_lite:latest + - name: arm64 + cpu: cortex-a53 + image: raspios_lite_arm64:latest + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + - uses: actions/cache/restore@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install + run: yarn install + - name: Compile + run: yarn run build + - name: rebuild node-pty + uses: pguyot/arm-runner-action@v2.5.2 + with: + image_additional_mb: 2000 + base_image: ${{ matrix.image }} + cpu: ${{ matrix.cpu }} + shell: bash + copy_artifact_path: target/node_modules/node-pty + copy_artifact_dest: target/node_modules + commands: | + wget https://nodejs.org/dist/v18.16.0/node-v18.16.0-linux-${{ matrix.name }}.tar.xz + tar -xJf node-v18.16.0-linux-${{ matrix.name }}.tar.xz + sudo cp node-v18.16.0-linux-${{ matrix.name }}/* /usr/local/ -R + npm run rebuild-node-pty + - name: chown node-pty + run: | + sudo chown -R $USER:$USER target/node_modules/node-pty + - name: Prepare v8 snapshot + if: matrix.name == 'armv7l' + run: | + sudo dpkg --add-architecture i386 + sudo apt update + sudo apt install -y libpcre2-8-0=10.34-7 --allow-downgrades + sudo apt install -y libglib2.0-0:i386 libexpat1:i386 + npm_config_arch=armv7l yarn run v8-snapshot:arch + - name: Build + run: yarn run electron-builder -l deb rpm AppImage --${{ matrix.name }} -c electron-builder-linux-ci.json + - name: Archive Build Artifacts + uses: LabhanshAgrawal/upload-artifact@v3 + with: + path: | + dist/*.snap + dist/*.AppImage + dist/*.deb + dist/*.rpm diff --git a/electron-builder-linux-ci.json b/electron-builder-linux-ci.json new file mode 100644 index 000000000000..a29fc86a5484 --- /dev/null +++ b/electron-builder-linux-ci.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json.schemastore.org/electron-builder", + "extends": "electron-builder.json", + "afterSign": null, + "npmRebuild": false +} diff --git a/electron-builder.json b/electron-builder.json index a2ad003a5eae..42c1422f7c52 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -20,33 +20,10 @@ "linux": { "category": "TerminalEmulator", "target": [ - { - "target": "deb", - "arch": [ - "x64", - "arm64" - ] - }, - { - "target": "AppImage", - "arch": [ - "x64", - "arm64" - ] - }, - { - "target": "rpm", - "arch": [ - "x64", - "arm64" - ] - }, - { - "target": "snap", - "arch": [ - "x64" - ] - } + "deb", + "AppImage", + "rpm", + "snap" ] }, "win": { diff --git a/package.json b/package.json index ebf2c1a52c58..acf85eec318e 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "start": "echo 'please run `yarn run dev` in one tab and then `yarn run app` in another one'", "app": "cross-env ELECTRONMON_LOGLEVEL=error electronmon target", "dev": "concurrently -n \"Webpack,TypeScript\" -c \"cyan.bold,blue.bold\" \"webpack -w\" \"tsc --build -v --pretty --watch --preserveWatchOutput\" -k", - "build": "cross-env NODE_ENV=production webpack && tsc -b -v", + "build": "cross-env NODE_ENV=production webpack && tsc -b -v && cross-env BABEL_ENV=production babel target/renderer/bundle.js --out-file target/renderer/bundle.js --no-comments --minified", "lint": "eslint . --ext .js,.jsx,.ts,.tsx,.json", "test": "yarn run lint && yarn run test:unit", "test:unit": "ava", @@ -14,7 +14,7 @@ "test:e2e": "ava --config ava-e2e.config.js", "postinstall": "yarn run v8-snapshot && webpack --config-name hyper-app && electron-builder install-app-deps && yarn run rebuild-node-pty && cpy --cwd=target node_modules \"../app/\" && husky install && yarn run generate-schema", "rebuild-node-pty": "electron-rebuild -f -o node-pty -m target", - "dist": "yarn run build && cross-env BABEL_ENV=production babel target/renderer/bundle.js --out-file target/renderer/bundle.js --no-comments --minified && electron-builder", + "dist": "yarn run build && electron-builder", "clean": "node ./bin/rimraf-standalone.js node_modules && node ./bin/rimraf-standalone.js ./app/node_modules && node ./bin/rimraf-standalone.js ./app/renderer", "v8-snapshot": "cross-env npm_config_arch=x64 yarn run v8-snapshot:arch && cross-env npm_config_arch=arm64 yarn run v8-snapshot:arch", "v8-snapshot:arch": "yarn run mk-snapshot && yarn run cp-snapshot",