name: "Build Action"
on:
  push:
    branches:
      - main
  workflow_dispatch:

permissions: write-all

jobs:
  Build-LiteLoader:
    runs-on: ubuntu-latest
    steps:
    - name: Clone Main Repository
      uses: actions/checkout@v4
      with:
          repository: 'NapNeko/NapCatQQ'
          submodules: true
          ref: main
          token: ${{ secrets.NAPCAT_BUILD }}
    - name: Use Node.js 20.X
      uses: actions/setup-node@v4
      with:
        node-version: 20.x
    - name: Build NuCat Framework
      run: |
          npm i
          cd napcat.webui
          npm i
          cd ..
          npm run build:framework
          cd dist
          npm i --omit=dev 
          rm package-lock.json
          cd ..
    - name: Upload Artifact
      uses: actions/upload-artifact@v4
      with:
        name: NapCat.Framework
        path: dist
  Build-Shell:
    runs-on: ubuntu-latest
    steps:
        - name: Clone Main Repository
          uses: actions/checkout@v4
          with:
                repository: 'NapNeko/NapCatQQ'
                submodules: true
                ref: main
                token: ${{ secrets.NAPCAT_BUILD }}
        - name: Use Node.js 20.X
          uses: actions/setup-node@v4
          with:
              node-version: 20.x
        - name: Build NuCat LiteLoader
          run: |
                npm i
                cd napcat.webui
                npm i
                cd ..
                npm run build:shell
                cd dist
                npm i --omit=dev
                rm package-lock.json
                cd ..
        - name: Upload Artifact
          uses: actions/upload-artifact@v4
          with:
              name: NapCat.Shell
              path: dist
