From 45021820ee9fe653043241777fb99689be5c6f37 Mon Sep 17 00:00:00 2001 From: Philip Peterson Date: Sat, 26 Apr 2025 00:28:45 -0700 Subject: [PATCH] wip --- .github/actions/build-linux-arm/action.yml | 113 +++++++++++++++++++++ .github/actions/build/action.yml | 30 +++--- .github/workflows/{nodejs.yml => ci.yml} | 38 ++++++- .github/workflows/release.yml | 56 ++++++++++ 4 files changed, 222 insertions(+), 15 deletions(-) create mode 100644 .github/actions/build-linux-arm/action.yml rename .github/workflows/{nodejs.yml => ci.yml} (54%) diff --git a/.github/actions/build-linux-arm/action.yml b/.github/actions/build-linux-arm/action.yml new file mode 100644 index 00000000..7098d345 --- /dev/null +++ b/.github/actions/build-linux-arm/action.yml @@ -0,0 +1,113 @@ +name: 'Build Linux ARM' +description: 'Cross-compiles Hyper app for ARMv7l and ARM64 using arm-runner' +inputs: + node-version: + description: 'Node.js version to use' + required: true + matrix-name: + description: 'Matrix name (arch)' + required: true + matrix-cpu: + description: 'CPU architecture' + required: true + matrix-image: + description: 'Base OS image for ARM emulation' + required: true + upload-artifact: + description: 'Whether to upload artifacts' + required: false + default: 'true' +runs: + using: 'composite' + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + + - name: Fix node-gyp and Python + shell: bash + run: | + python3 -m pip install packaging setuptools + + - name: Get yarn cache directory path + shell: bash + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache/restore@v4 + 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 dependencies and tools + shell: bash + run: | + yarn install + sudo apt update + sudo apt install libarchive-tools + + - name: Compile + shell: bash + run: yarn run build + + - name: Rebuild node-pty for ARM + uses: pguyot/arm-runner-action@v2.6.5 + with: + image_additional_mb: 2000 + base_image: ${{ inputs.matrix-image }} + cpu: ${{ inputs.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-${{ inputs.matrix-name }}.tar.xz + tar -xJf node-v18.16.0-linux-${{ inputs.matrix-name }}.tar.xz + sudo cp node-v18.16.0-linux-${{ inputs.matrix-name }}/* /usr/local/ -R + npm run rebuild-node-pty + + - name: Chown rebuilt node-pty + shell: bash + run: | + sudo chown -R $USER:$USER target/node_modules/node-pty + + - name: Prepare v8 snapshot (only armv7l) + if: ${{ inputs.matrix-name == 'armv7l' }} + shell: bash + run: | + sudo dpkg --add-architecture i386 + sudo apt update + sudo apt install -y libglib2.0-0:i386 libexpat1:i386 libgcc-s1:i386 + npm_config_arch=armv7l yarn run v8-snapshot:arch + + - name: Build final Electron App for ARM + shell: bash + run: | + yarn run electron-builder -l deb rpm AppImage pacman --${{ inputs.matrix-name }} -c electron-builder-linux-ci.json + env: + GH_TOKEN: ${{ env.GH_TOKEN }} + + - name: Archive Build Artifacts + if: ${{ inputs.upload-artifact == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: hyper-linux-${{ inputs.matrix-name }} + path: | + dist/*.snap + dist/*.AppImage + dist/*.deb + dist/*.rpm + dist/*.pacman + +# - name: Run E2E Tests on Linux +# if: runner.os == 'Linux' +# uses: GabrielBB/xvfb-action@v1.7 +# with: +# run: | +# yarn run test +# \ No newline at end of file diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index b14291fe..b1a0bc0c 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -10,6 +10,10 @@ inputs: matrix-os: description: 'Matrix OS' required: true + upload-artifact: + description: 'Whether to upload artifacts' + required: false + default: 'true' runs: using: 'composite' steps: @@ -138,21 +142,19 @@ runs: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }} + - name: Archive Build Artifacts + if: ${{ inputs.upload-artifact == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: hyper-${{ runner.os }} + path: | + dist/*.dmg + dist/*.snap + dist/*.AppImage + dist/*.deb + dist/*.pacman + dist/*.exe - - -# - name: Archive Build Artifacts -# uses: actions/upload-artifact@v4 -# with: -# name: hyper-${{ runner.os }} -# path: | -# dist/*.dmg -# dist/*.snap -# dist/*.AppImage -# dist/*.deb -# dist/*.pacman -# dist/*.exe -# # - name: Run E2E Tests (non-Linux) # if: runner.os != 'Linux' # shell: bash diff --git a/.github/workflows/nodejs.yml b/.github/workflows/ci.yml similarity index 54% rename from .github/workflows/nodejs.yml rename to .github/workflows/ci.yml index 02863b7a..c90b20a1 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} matrix-os: ubuntu-latest matrix-name: ubuntu + upload-artifact: false build-macos: name: Build macOS @@ -48,4 +49,39 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} matrix-os: macos-latest - matrix-name: macos \ No newline at end of file + matrix-name: macos + upload-artifact: false + + # ARM Linux: + + build-linux-armv7l: + name: Build Linux ARMv7l + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build ARMv7l + uses: ./.github/actions/build-linux-arm + with: + node-version: ${{ env.NODE_VERSION }} + matrix-name: armv7l + matrix-cpu: cortex-a8 + matrix-image: raspios_lite:latest + upload-artifact: false + + build-linux-arm64: + name: Build Linux ARM64 + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build ARM64 + uses: ./.github/actions/build-linux-arm + with: + node-version: ${{ env.NODE_VERSION }} + matrix-name: arm64 + matrix-cpu: cortex-a53 + matrix-image: raspios_lite_arm64:latest + upload-artifact: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e828872c..7f0414a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} matrix-os: ubuntu-latest matrix-name: ubuntu + upload-artifact: true build-macos: name: Build macOS @@ -48,12 +49,67 @@ jobs: node-version: ${{ env.NODE_VERSION }} matrix-os: macos-latest matrix-name: macos + upload-artifact: true + + build-windows: + name: Build Windows + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build + uses: ./.github/actions/build + with: + node-version: ${{ env.NODE_VERSION }} + matrix-os: windows-latest + matrix-name: win + upload-artifact: true + + # ARM Linux: + + build-linux-armv7l: + name: Build Linux ARMv7l + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build ARMv7l + uses: ./.github/actions/build-linux-arm + with: + node-version: ${{ env.NODE_VERSION }} + matrix-name: armv7l + matrix-cpu: cortex-a8 + matrix-image: raspios_lite:latest + upload-artifact: true + + build-linux-arm64: + name: Build Linux ARM64 + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build ARM64 + uses: ./.github/actions/build-linux-arm + with: + node-version: ${{ env.NODE_VERSION }} + matrix-name: arm64 + matrix-cpu: cortex-a53 + matrix-image: raspios_lite_arm64:latest + upload-artifact: true + + ### upload-release: name: Upload and Create Release needs: - build-ubuntu - build-macos + - build-windows + - build-linux-armv7l + - build-linux-arm64 runs-on: ubuntu-latest steps: - name: Download all artifacts