|
| 1 | +name: CI / CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +env: |
| 9 | + LLVM_VERSION: 15 |
| 10 | + LIBNODE_VERSION: 22.12.0 |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ubuntu-22.04, windows-2022] |
| 18 | + |
| 19 | + name: Build with ${{ matrix.os == 'windows-2022' && 'Win-MSVC' || 'Ubuntu-Clang' }} |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - uses: xmake-io/github-action-setup-xmake@v1 |
| 27 | + # with: |
| 28 | + # xmake-version: branch@master |
| 29 | + |
| 30 | + - uses: actions/cache@v4 |
| 31 | + with: |
| 32 | + path: | |
| 33 | + ~/AppData/Local/.xmake |
| 34 | + key: xmake-${{ hashFiles('xmake.lua') }} |
| 35 | + restore-keys: | |
| 36 | + xmake- |
| 37 | +
|
| 38 | + - name: Set up Clang(Linux) |
| 39 | + if: runner.os == 'Linux' |
| 40 | + run: | |
| 41 | + sudo apt-get update -y -q |
| 42 | + sudo apt-get install -y -q lsb-release wget software-properties-common gnupg |
| 43 | + sudo wget https://apt.llvm.org/llvm.sh |
| 44 | + sudo chmod +x llvm.sh |
| 45 | + sudo ./llvm.sh ${{env.LLVM_VERSION}} |
| 46 | + sudo apt-get install -y -q libc++-${{env.LLVM_VERSION}}-dev libc++abi-${{env.LLVM_VERSION}}-dev |
| 47 | + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${{env.LLVM_VERSION}} 100 |
| 48 | + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${{env.LLVM_VERSION}} 100 |
| 49 | + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{env.LLVM_VERSION}} 100 |
| 50 | + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{env.LLVM_VERSION}} 100 |
| 51 | + sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-${{env.LLVM_VERSION}} 100 |
| 52 | + sudo update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-${{env.LLVM_VERSION}} 100 |
| 53 | +
|
| 54 | + - run: | |
| 55 | + xmake repo -u |
| 56 | +
|
| 57 | + - run: | |
| 58 | + xmake f -a x64 -m release -v -y |
| 59 | +
|
| 60 | + - run: | |
| 61 | + xmake -v -y |
| 62 | +
|
| 63 | + - uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: ${{ github.event.repository.name }}-${{ runner.os }}-x64-${{ github.sha }} |
| 66 | + path: | |
| 67 | + bin/ |
| 68 | +
|
| 69 | + pack: |
| 70 | + needs: build |
| 71 | + strategy: |
| 72 | + fail-fast: false |
| 73 | + matrix: |
| 74 | + platform: ["Windows", "Linux"] |
| 75 | + |
| 76 | + name: Package ${{ matrix.platform }} platform dependencies |
| 77 | + runs-on: ubuntu-22.04 |
| 78 | + steps: |
| 79 | + - uses: actions/download-artifact@v4 |
| 80 | + with: |
| 81 | + name: ${{ github.event.repository.name }}-${{ matrix.platform }}-x64-${{ github.sha }} |
| 82 | + path: bin/ |
| 83 | + |
| 84 | + - name: Download depends |
| 85 | + run: | |
| 86 | + curl -o bin-linux.zip -L https://github.com/IceBlcokMC/node/releases/download/v${{env.LIBNODE_VERSION}}/bin-linux.zip |
| 87 | + curl -o bin-windows.zip -L https://github.com/IceBlcokMC/node/releases/download/v${{env.LIBNODE_VERSION}}/bin-windows.zip |
| 88 | + curl -o node_modules.zip -L https://github.com/IceBlcokMC/node/releases/download/v${{env.LIBNODE_VERSION}}/node_modules.zip |
| 89 | +
|
| 90 | + - name: Unzip depends |
| 91 | + run: | |
| 92 | + mkdir deps |
| 93 | + mkdir deps/node_modules |
| 94 | + unzip -a -q bin-linux.zip -d deps/ |
| 95 | + unzip -a -q bin-windows.zip -d deps/ |
| 96 | + unzip -a -q node_modules.zip -d deps/node_modules/ |
| 97 | +
|
| 98 | + - name: Pack |
| 99 | + run: | |
| 100 | + mkdir full |
| 101 | + mkdir full/plugins |
| 102 | +
|
| 103 | + cp -r bin/* full/plugins/ |
| 104 | + cp -a deps/node_modules/. full/plugins/js_engine/node_modules/ |
| 105 | +
|
| 106 | + if [ "${{ matrix.platform }}" == "Windows" ]; then |
| 107 | + cp deps/libnode.dll full/ |
| 108 | + cp deps/node.exe full/ |
| 109 | + else |
| 110 | + cp deps/libnode.so.127 full/ |
| 111 | + cp deps/node full/ |
| 112 | + fi |
| 113 | +
|
| 114 | + - uses: actions/upload-artifact@v4 |
| 115 | + with: |
| 116 | + name: ${{ github.event.repository.name }}-${{ matrix.platform }}-full-x64-${{ github.sha }} |
| 117 | + include-hidden-files: true |
| 118 | + path: | |
| 119 | + full/ |
0 commit comments