🏗️ Use xmake #381
Workflow file for this run
This file contains 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
--- | |
'on': | |
push: | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
workflow_dispatch: | |
# https://github.com/softprops/action-gh-release/issues/236 | |
permissions: | |
contents: write | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- runs-on: ubuntu-latest | |
shell: bash | |
- runs-on: macos-latest | |
shell: bash | |
- 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' | |
# https://github.com/xmake-io/xmake/discussions/5699 | |
# xmake needs git | |
# xmake search cxx for MinGW | |
run: | | |
pacman -Sy --noconfirm mingw-w64-x86_64-pkg-config \ | |
mingw-w64-x86_64-librime mingw-w64-x86_64-nodejs \ | |
mingw-w64-x86_64-gcc mingw-w64-x86_64-xmake git | |
ln -s c++ /mingw64/bin/cxx | |
- 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 add-apt-repository ppa:xmake-io/xmake | |
sudo apt-get -y update | |
sudo apt-get -y install librime-dev librime1 xmake | |
- 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'<nixpkgs>' librime xmake | |
echo "$HOME/.nix-profile/bin" >> "${GITHUB_PATH}" | |
- name: Build | |
run: | | |
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 | |
with: | |
files: '*.tgz' | |
- name: Publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} | |
NODE_ENV: production | |
run: | | |
npm publish |