name: Build NapCat Artifacts on: workflow_dispatch: push: branches: - main permissions: write-all jobs: typecheck-and-test: name: Type Check & Test runs-on: ubuntu-latest steps: - name: Clone Main Repository uses: actions/checkout@v5 with: fetch-depth: 0 - name: Setup pnpm uses: pnpm/action-setup@v4 with: version: 9 run_install: false - name: Use Node.js 20.x uses: actions/setup-node@v6 with: node-version: 20.x - name: Install Dependencies run: pnpm i - name: Type Check run: pnpm run typecheck - name: Run Tests run: pnpm test build: name: Build NapCat.${{ matrix.target.name }} needs: typecheck-and-test runs-on: ubuntu-latest strategy: matrix: target: - name: Framework build_cmd: build:framework src_dir: packages/napcat-framework/dist dist_dir: framework-dist - name: Shell build_cmd: build:shell src_dir: packages/napcat-shell/dist dist_dir: shell-dist steps: - name: Clone Main Repository uses: actions/checkout@v5 with: fetch-depth: 0 - name: Setup pnpm uses: pnpm/action-setup@v4 with: version: 9 run_install: false - name: Use Node.js 20.x uses: actions/setup-node@v6 with: node-version: 20.x - name: Generate Version run: | LATEST_TAG=$(git describe --tags --abbrev=0 --match "v[0-9]*.[0-9]*.[0-9]*" 2>/dev/null || echo "v0.0.0") BASE_VERSION="${LATEST_TAG#v}" SHORT_SHA="${GITHUB_SHA::7}" VERSION="${BASE_VERSION}-main.${{ github.run_number }}+${SHORT_SHA}" echo "NAPCAT_VERSION=${VERSION}" >> $GITHUB_ENV echo "Latest tag: ${LATEST_TAG}" echo "Build version: ${VERSION}" - name: Build NapCat.${{ matrix.target.name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NAPCAT_VERSION: ${{ env.NAPCAT_VERSION }} run: | pnpm i pnpm --filter napcat-webui-frontend run build || exit 1 pnpm run ${{ matrix.target.build_cmd }} pnpm --filter napcat-plugin-builtin run build || exit 1 mv ${{ matrix.target.src_dir }} ${{ matrix.target.dist_dir }} cd ${{ matrix.target.dist_dir }} npm install --omit=dev rm ./package-lock.json || exit 0 - name: Upload Artifact uses: actions/upload-artifact@v6 with: name: NapCat.${{ matrix.target.name }} path: ${{ matrix.target.dist_dir }}