From 61087a76f1599d838683098ea292541e75806166 Mon Sep 17 00:00:00 2001
From: Daniel Lockyer <hi@daniellockyer.com>
Date: Thu, 28 Apr 2022 08:15:36 +0100
Subject: [PATCH] Added `host` architecture concept to CI

- as we move towards cross-compiling in native GitHub Actions, we need a
  way to differentiate between the host and target architecture
- this adds a concept of `host` to CI and passes the target architecture
  to `node-pre-gyp`
---
 .github/workflows/ci.yml | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e1c1fcad4..bf54a21da 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -22,6 +22,8 @@ jobs:
           - macos-latest
           - ubuntu-latest
           - windows-latest
+        host:
+          - x64
         target:
           - x64
         node:
@@ -37,14 +39,15 @@ jobs:
         include:
           - os: windows-latest
             node: 16
+            host: x64
             target: x86
-    name: ${{ matrix.os }} (node=${{ matrix.node }}, target=${{ matrix.target }})
+    name: ${{ matrix.os }} (node=${{ matrix.node }}, host=${{ matrix.host }}, target=${{ matrix.target }})
     steps:
       - uses: actions/checkout@v3
       - uses: actions/setup-node@v3
         with:
           node-version: ${{ matrix.node }}
-          architecture: ${{ matrix.target }}
+          architecture: ${{ matrix.host }}
 
       - name: Add msbuild to PATH
         uses: microsoft/setup-msbuild@v1.1
@@ -66,10 +69,10 @@ jobs:
           echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV
 
       - name: Configure build
-        run: yarn node-pre-gyp configure
+        run: yarn node-pre-gyp configure --target_arch=${{ matrix.target }}
 
       - name: Build binaries
-        run: yarn node-pre-gyp build
+        run: yarn node-pre-gyp build --target_arch=${{ matrix.target }}
 
       - name: Print binary info
         if: contains(matrix.os, 'ubuntu')
@@ -84,7 +87,7 @@ jobs:
         run: yarn test
 
       - name: Package prebuilt binaries
-        run: yarn node-pre-gyp package
+        run: yarn node-pre-gyp package --target_arch=${{ matrix.target }}
 
       - name: Upload binaries to commit artifacts
         uses: actions/upload-artifact@v3