prebuilt-binaries-cross #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: prebuilt-binaries-cross | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: New version | |
| required: false | |
| type: string | |
| publish: | |
| description: Publish | |
| required: false | |
| default: false | |
| type: boolean | |
| push: | |
| tags: | |
| - "*" | |
| permissions: | |
| contents: write | |
| actions: read | |
| env: | |
| PREBUILT_DIR: prebuilt-artifacts | |
| jobs: | |
| metadata: | |
| name: Resolve Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.versions.outputs.version }} | |
| tag: ${{ steps.versions.outputs.tag }} | |
| should_publish: ${{ steps.versions.outputs.should_publish }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: versions | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| INPUT_VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || '' }} | |
| PUBLISH_INPUT: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.publish || 'true' }} | |
| RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || '' }} | |
| run: ./.github/scripts/resolve-version.sh | |
| linux-cross: | |
| name: Linux cross (${{ matrix.slug }}) | |
| needs: metadata | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - slug: x64 | |
| npm_arch: x64 | |
| deb_arch: amd64 | |
| gnu_triplet: x86_64-linux-gnu | |
| cc: gcc | |
| cxx: g++ | |
| ar: ar | |
| ranlib: ranlib | |
| toolchain_packages: "" | |
| - slug: arm64 | |
| npm_arch: arm64 | |
| deb_arch: arm64 | |
| gnu_triplet: aarch64-linux-gnu | |
| cc: aarch64-linux-gnu-gcc | |
| cxx: aarch64-linux-gnu-g++ | |
| ar: aarch64-linux-gnu-ar | |
| ranlib: aarch64-linux-gnu-ranlib | |
| toolchain_packages: crossbuild-essential-arm64 | |
| - slug: armhf | |
| npm_arch: arm | |
| deb_arch: armhf | |
| gnu_triplet: arm-linux-gnueabihf | |
| cc: arm-linux-gnueabihf-gcc | |
| cxx: arm-linux-gnueabihf-g++ | |
| ar: arm-linux-gnueabihf-ar | |
| ranlib: arm-linux-gnueabihf-ranlib | |
| toolchain_packages: crossbuild-essential-armhf | |
| - slug: riscv64 | |
| npm_arch: riscv64 | |
| deb_arch: riscv64 | |
| gnu_triplet: riscv64-linux-gnu | |
| cc: riscv64-linux-gnu-gcc | |
| cxx: riscv64-linux-gnu-g++ | |
| ar: riscv64-linux-gnu-ar | |
| ranlib: riscv64-linux-gnu-ranlib | |
| toolchain_packages: "gcc-riscv64-linux-gnu g++-riscv64-linux-gnu" | |
| - slug: loong64 | |
| npm_arch: loong64 | |
| deb_arch: loongarch64 | |
| gnu_triplet: loongarch64-linux-gnu | |
| cc: loongarch64-linux-gnu-gcc | |
| cxx: loongarch64-linux-gnu-g++ | |
| ar: loongarch64-linux-gnu-ar | |
| ranlib: loongarch64-linux-gnu-ranlib | |
| toolchain_packages: "gcc-loongarch64-linux-gnu g++-loongarch64-linux-gnu" | |
| - slug: ppc64le | |
| npm_arch: ppc64 | |
| deb_arch: ppc64el | |
| gnu_triplet: powerpc64le-linux-gnu | |
| cc: powerpc64le-linux-gnu-gcc | |
| cxx: powerpc64le-linux-gnu-g++ | |
| ar: powerpc64le-linux-gnu-ar | |
| ranlib: powerpc64le-linux-gnu-ranlib | |
| toolchain_packages: crossbuild-essential-ppc64el | |
| - slug: s390x | |
| npm_arch: s390x | |
| deb_arch: s390x | |
| gnu_triplet: s390x-linux-gnu | |
| cc: s390x-linux-gnu-gcc | |
| cxx: s390x-linux-gnu-g++ | |
| ar: s390x-linux-gnu-ar | |
| ranlib: s390x-linux-gnu-ranlib | |
| toolchain_packages: crossbuild-essential-s390x | |
| env: | |
| TARGET_PLATFORM: linux | |
| PACKAGE_VERSION: ${{ needs.metadata.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Install cross toolchains and headers | |
| env: | |
| DEB_ARCH: ${{ matrix.deb_arch }} | |
| TOOLCHAIN_PACKAGES: ${{ matrix.toolchain_packages }} | |
| run: ./.github/scripts/linux/install-cross-deps.sh | |
| - name: Install npm dependencies | |
| run: npm install --no-fund --no-audit --ignore-scripts | |
| - name: Build native module (cross) | |
| env: | |
| npm_config_build_from_source: true | |
| npm_config_arch: ${{ matrix.npm_arch }} | |
| npm_config_target_arch: ${{ matrix.npm_arch }} | |
| CC: ${{ matrix.cc }} | |
| CXX: ${{ matrix.cxx }} | |
| AR: ${{ matrix.ar }} | |
| RANLIB: ${{ matrix.ranlib }} | |
| GNU_TRIPLET: ${{ matrix.gnu_triplet }} | |
| NPM_ARCH: ${{ matrix.npm_arch }} | |
| run: ./.github/scripts/linux/build-cross.sh | |
| - name: Verify binary architecture | |
| run: ./.github/scripts/linux/verify-elf.sh '${{ matrix.slug }}' build/Release/keymapping.node | |
| - name: Package artifact | |
| run: ./.github/scripts/package-tar.sh '${{ env.TARGET_PLATFORM }}' '${{ matrix.slug }}' '${{ env.PACKAGE_VERSION }}' | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-keymap-${{ env.TARGET_PLATFORM }}-${{ matrix.slug }} | |
| path: | | |
| ${{ env.PREBUILT_DIR }}/native-keymap-${{ env.PACKAGE_VERSION }}-${{ env.TARGET_PLATFORM }}-${{ matrix.slug }}.tar.gz | |
| ${{ env.PREBUILT_DIR }}/native-keymap-${{ env.PACKAGE_VERSION }}-${{ env.TARGET_PLATFORM }}-${{ matrix.slug }}.tar.gz.sha256 | |
| macos-cross: | |
| name: macOS cross (${{ matrix.label }}) | |
| needs: metadata | |
| runs-on: macos-14 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - label: x64 | |
| npm_arch: x64 | |
| clang_arch: x86_64 | |
| deployment_target: "10.13" | |
| - label: arm64 | |
| npm_arch: arm64 | |
| clang_arch: arm64 | |
| deployment_target: "11.0" | |
| env: | |
| TARGET_PLATFORM: darwin | |
| PACKAGE_VERSION: ${{ needs.metadata.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Install npm dependencies | |
| run: npm install --no-fund --no-audit --ignore-scripts | |
| - name: Build native module (cross) | |
| env: | |
| npm_config_build_from_source: true | |
| npm_config_arch: ${{ matrix.npm_arch }} | |
| npm_config_target_arch: ${{ matrix.npm_arch }} | |
| NPM_ARCH: ${{ matrix.npm_arch }} | |
| CLANG_ARCH: ${{ matrix.clang_arch }} | |
| DEPLOYMENT_TARGET: ${{ matrix.deployment_target }} | |
| run: ./.github/scripts/macos/build-cross.sh | |
| - name: Verify binary architecture | |
| run: ./.github/scripts/macos/verify-macho.sh '${{ matrix.label }}' build/Release/keymapping.node | |
| - name: Package artifact | |
| run: ./.github/scripts/package-tar.sh '${{ env.TARGET_PLATFORM }}' '${{ matrix.label }}' '${{ env.PACKAGE_VERSION }}' | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-keymap-${{ env.TARGET_PLATFORM }}-${{ matrix.label }} | |
| path: | | |
| ${{ env.PREBUILT_DIR }}/native-keymap-${{ env.PACKAGE_VERSION }}-${{ env.TARGET_PLATFORM }}-${{ matrix.label }}.tar.gz | |
| ${{ env.PREBUILT_DIR }}/native-keymap-${{ env.PACKAGE_VERSION }}-${{ env.TARGET_PLATFORM }}-${{ matrix.label }}.tar.gz.sha256 | |
| windows-cross: | |
| name: Windows cross (${{ matrix.arch }}) | |
| needs: metadata | |
| runs-on: windows-2022 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: x64 | |
| vs_arch: x64 | |
| - arch: arm64 | |
| vs_arch: amd64_arm64 | |
| env: | |
| TARGET_PLATFORM: win32 | |
| PACKAGE_VERSION: ${{ needs.metadata.outputs.version }} | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Install npm dependencies | |
| run: npm install --no-fund --no-audit --ignore-scripts | |
| - name: Setup MSVC toolchain | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: ${{ matrix.vs_arch }} | |
| - name: Build native module (cross) | |
| env: | |
| npm_config_build_from_source: true | |
| npm_config_arch: ${{ matrix.arch }} | |
| npm_config_target_arch: ${{ matrix.arch }} | |
| run: npx node-gyp rebuild --arch=${{ matrix.arch }} | |
| - name: Verify binary architecture | |
| run: ./.github/scripts/windows/verify-pe.sh '${{ matrix.arch }}' 'build/Release/keymapping.node' | |
| - name: Package artifact | |
| run: ./.github/scripts/package-tar.sh '${{ env.TARGET_PLATFORM }}' '${{ matrix.arch }}' '${{ env.PACKAGE_VERSION }}' | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: native-keymap-${{ env.TARGET_PLATFORM }}-${{ matrix.arch }} | |
| path: | | |
| ${{ env.PREBUILT_DIR }}/native-keymap-${{ env.PACKAGE_VERSION }}-${{ env.TARGET_PLATFORM }}-${{ matrix.arch }}.tar.gz | |
| ${{ env.PREBUILT_DIR }}/native-keymap-${{ env.PACKAGE_VERSION }}-${{ env.TARGET_PLATFORM }}-${{ matrix.arch }}.tar.gz.sha256 | |
| publish: | |
| name: Publish Release | |
| needs: | |
| - metadata | |
| - linux-cross | |
| - macos-cross | |
| - windows-cross | |
| if: needs.metadata.outputs.should_publish == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js for npm publish | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| registry-url: https://registry.npmjs.org | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: collected-artifacts | |
| - name: Flatten artifact structure | |
| run: ./.github/scripts/flatten-artifacts.sh | |
| - name: Publish package to npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: ./.github/scripts/npm-publish.sh | |
| - name: Publish release assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.metadata.outputs.tag }} | |
| name: native-keymap ${{ needs.metadata.outputs.tag }} | |
| files: release/* | |
| draft: false | |
| prerelease: false |