114 lines
3.6 KiB
YAML
114 lines
3.6 KiB
YAML
name: Build NapCat Artifacts
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
permissions: write-all
|
|
|
|
jobs:
|
|
windows-loader-test:
|
|
name: Windows Loader Test
|
|
needs: build
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: actions/download-artifact@v7
|
|
with:
|
|
name: NapCat.Shell
|
|
path: shell-dist
|
|
- name: Verify Windows loader file queries
|
|
shell: pwsh
|
|
run: |
|
|
cmake -S .github/tests/windows-loader -B "$env:RUNNER_TEMP/windows-loader-test" -A x64
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
cmake --build "$env:RUNNER_TEMP/windows-loader-test" --config Release
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
& "$env:RUNNER_TEMP/windows-loader-test/Release/windows-loader-test.exe" "$pwd/shell-dist/NapCatWinBootHook.dll" "$pwd/shell-dist/loadNapCat.js"
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
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 }}
|
|
# --omit=dev still resolves dev peer dependencies; remove build tooling first.
|
|
npm pkg delete devDependencies
|
|
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 }}
|