From e881fbe7cbd572f5821be076dcaf54356e318e27 Mon Sep 17 00:00:00 2001 From: "Wu, Zhenyu" Date: Thu, 5 Dec 2024 14:35:21 +0800 Subject: [PATCH] :green_heart: Enable CI for macos --- .github/workflows/main.yml | 65 ++++++++++++++++++++++++++++++++++---- package.json | 2 +- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6782b1e..ad68fd9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,36 +13,89 @@ permissions: contents: write jobs: - deploy: - runs-on: ubuntu-latest + build: + strategy: + fail-fast: false + matrix: + include: + - runs-on: ubuntu-latest + shell: bash + - runs-on: macos-latest + shell: bash + # gyp only support msbuild/msvc, + # pkg-config --libs --msvc-syntax rime + # give path of rime.lib + # however, msys2 uses rime.dll.a + # force gyp to use make + # gyp tells no toolset found + # - runs-on: windows-latest + # shell: msys2 + runs-on: ${{matrix.runs-on}} + defaults: + run: + shell: ${{matrix.shell}} {0} steps: - uses: actions/checkout@v4 + - uses: msys2/setup-msys2@v2 + if: runner.os == 'Windows' + - name: Install dependencies + if: runner.os == 'Windows' + run: | + pacman -Sy --noconfirm mingw-w64-x86_64-pkg-config \ + mingw-w64-x86_64-librime mingw-w64-x86_64-nodejs - name: Enable corepack run: | corepack enable - uses: actions/setup-node@v4 + # if use cmd, not msys2 + if: runner.os != 'Windows' with: node-version: latest registry-url: https://registry.npmjs.org cache: 'yarn' - name: Install dependencies + if: runner.os == 'Linux' run: | sudo apt-get -y update sudo apt-get -y install librime-dev librime1 + - uses: cachix/install-nix-action@v24 + if: runner.os == 'macOS' + with: + nix_path: nixpkgs=channel:nixpkgs-unstable + extra_nix_config: | + experimental-features = nix-command flakes + access-tokens = github.com=${{secrets.GITHUB_TOKEN}} + - name: Install dependencies + if: runner.os == 'macOS' + run: | + nix-env -if'' librime - name: Build run: | - yarn - yarn pack + PKG_CONFIG_PATH="$HOME/.nix-profile/lib/pkgconfig" yarn install + PKG_CONFIG_PATH="$HOME/.nix-profile/lib/pkgconfig" yarn pack env: NODE_ENV: production + - uses: actions/upload-artifact@v4 + with: + name: artifact-${{matrix.runs-on}} + path: | + prebuilds/* + + publish: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/download-artifact@v4 + with: + pattern: artifact-* + merge-multiple: true + path: prebuilds - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') with: files: '*.tgz' - name: Publish env: NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} NODE_ENV: production - if: startsWith(github.ref, 'refs/tags/') run: | npm publish diff --git a/package.json b/package.json index 43fe71e..9decc07 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "coc": "^0.0.80" }, "scripts": { - "install": "node-gyp clean && node-gyp configure -- -fcompile_commands_json && ln -s Release/compile_commands.json build && node-gyp configure -- -fmake && make -Cbuild", + "install": "node-gyp-build && node-gyp configure -- -fcompile_commands_json && ln -s Release/compile_commands.json build", "lint": "eslint src --ext ts", "clean": "rimraf lib", "watch": "node esbuild.js --watch",