aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/macos.yml
blob: 6dede90ae73bacc16fc10832f8fc3c80541ae611 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: macOS

on:
  push:
    branches: [ main ]
    tags: 'v*.*.*'
  pull_request:
    branches: [ main ]
  workflow_dispatch:

jobs:
  build:
    name: Build & Test
    runs-on: macos-latest
    if: "startsWith(github.ref, 'refs/tags/') || !contains(github.event.head_commit.message, '[skip CI]')"
    steps:
      - uses: actions/checkout@v2
      - name: build-test
        run: |
          brew install luarocks
          sudo luarocks install busted
          sudo luarocks make
          make test
      - name: luarocks upload
        if: startsWith(github.ref, 'refs/tags/')
        run: |
          ./yue -e spec/inputs/luarocks_upload.yue ${{ secrets.LUAROCKS_KEY }}
      - name: build for luajit
        if: startsWith(github.ref, 'refs/tags/')
        run: |
          git clone https://github.com/LuaJIT/LuaJIT.git
          cd LuaJIT
          TARGET_FLAGS="-arch x86_64" MACOSX_DEPLOYMENT_TARGET=11 make
          mkdir x86_64
          mv src/libluajit.a x86_64/liblua.a
          MACOSX_DEPLOYMENT_TARGET=11 make clean
          TARGET_FLAGS="-arch arm64" MACOSX_DEPLOYMENT_TARGET=11 make
          mkdir arm64
          mv src/libluajit.a arm64/liblua.a
          cd ..
          make shared LUAI=LuaJIT/src LUAL=LuaJIT/x86_64 TARGET_FLAGS="-arch x86_64"
          mv bin/shared/yue.so yue_x86_64.so
          make clean
          make shared LUAI=LuaJIT/src LUAL=LuaJIT/arm64 TARGET_FLAGS="-arch arm64"
          lipo -create yue_x86_64.so bin/shared/yue.so -output yue.so
          zip -r yue-macos-universal-luajit-so.zip yue.so
      - name: release
        uses: softprops/action-gh-release@v1
        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: |
            ./yue-macos-universal-luajit-so.zip
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}