mirror of
https://github.com/lobehub/lobehub.git
synced 2026-09-20 04:56:13 +08:00
b65aae96b6
* 👷 build: migrate workspace to pnpm 12 pnpm 12 no longer reads the package.json "pnpm" field, only honours auth and registry keys from .npmrc, and requires allowBuilds instead of onlyBuiltDependencies. Move every project setting into pnpm-workspace.yaml and keep the previously effective overrides and build allowlist. * 👷 build: resolve desktop and cli workspaces on pnpm 12 pnpm 12 no longer accepts './'-prefixed workspace package globs, so the desktop stub path is now relative without the prefix. Migrate the remaining package.json "pnpm" fields into the desktop and cli pnpm-workspace.yaml files. * 👷 build: list protobufjs in the desktop build allowlist pnpm 12 fails the install with ERR_PNPM_IGNORED_BUILDS when a script-bearing dependency is missing from allowBuilds. protobufjs only appears in the desktop graph on Linux, so it was absent from the previous allowlist. * 👷 build: relink root workspace members before the desktop typecheck pnpm 12 writes broken relative symlinks for workspace members that live outside the desktop workspace root (../../packages/*), so tsgo cannot resolve sibling packages from source. Installing the root workspace after the desktop install rewrites those links correctly.
102 lines
3.9 KiB
YAML
102 lines
3.9 KiB
YAML
name: Bundle Analyzer
|
|
|
|
on:
|
|
workflow_dispatch: {}
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
|
|
env:
|
|
NODE_VERSION: 24.11.1
|
|
|
|
jobs:
|
|
bundle-analyzer:
|
|
name: Analyze Bundle Size
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup environment
|
|
uses: ./.github/actions/setup-env
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Install dependencies
|
|
run: pnpm i
|
|
|
|
- name: Ensure lockfile exists
|
|
run: |
|
|
# pnpm 12 reads only auth/registry keys from .npmrc, and `lockfile: false`
|
|
# lives in pnpm-workspace.yaml — force lockfile generation with the CLI flag.
|
|
if [ ! -f "pnpm-lock.yaml" ]; then
|
|
echo "Generating pnpm-lock.yaml..."
|
|
pnpm i --lockfile
|
|
fi
|
|
|
|
- name: Generate build secrets
|
|
id: generate-secret
|
|
run: echo "secret=$(openssl rand -base64 32)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build with bundle analyzer
|
|
run: npm run build:analyze || true
|
|
env:
|
|
NODE_OPTIONS: --max-old-space-size=81920
|
|
KEY_VAULTS_SECRET: ${{ secrets.KEY_VAULTS_SECRET || steps.generate-secret.outputs.secret }}
|
|
|
|
- name: Prepare analyzer reports
|
|
run: |
|
|
mkdir -p bundle-report
|
|
# Copy analyzer HTML reports if they exist
|
|
if [ -d ".next/analyze" ]; then
|
|
cp -r .next/analyze/* bundle-report/ || true
|
|
fi
|
|
# Also check if reports are in .vercel/output
|
|
if [ -d ".vercel/output/.next/analyze" ]; then
|
|
cp -r .vercel/output/.next/analyze/* bundle-report/ || true
|
|
fi
|
|
# Include pnpm lockfile for reproducible builds
|
|
if [ -f "pnpm-lock.yaml" ]; then
|
|
cp pnpm-lock.yaml bundle-report/pnpm-lock.yaml
|
|
echo "Copied pnpm-lock.yaml to bundle-report"
|
|
else
|
|
echo "Warning: pnpm-lock.yaml not found"
|
|
fi
|
|
# Create a summary with build metadata
|
|
echo "# Bundle Analysis Report" > bundle-report/README.md
|
|
echo "" >> bundle-report/README.md
|
|
echo "**Build Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> bundle-report/README.md
|
|
echo "**Commit:** ${{ github.sha }}" >> bundle-report/README.md
|
|
echo "**Branch:** ${{ github.ref_name }}" >> bundle-report/README.md
|
|
echo "" >> bundle-report/README.md
|
|
echo "## How to view" >> bundle-report/README.md
|
|
echo "" >> bundle-report/README.md
|
|
echo "1. Download the \`bundle-report\` artifact from this workflow run" >> bundle-report/README.md
|
|
echo "2. Extract the archive" >> bundle-report/README.md
|
|
echo "3. Open \`client.html\` and \`server.html\` in your browser" >> bundle-report/README.md
|
|
echo "" >> bundle-report/README.md
|
|
echo "## Files in this report" >> bundle-report/README.md
|
|
echo "" >> bundle-report/README.md
|
|
echo "- \`client.html\` - Client-side bundle analysis" >> bundle-report/README.md
|
|
echo "- \`server.html\` - Server-side bundle analysis" >> bundle-report/README.md
|
|
echo "- \`pnpm-lock.yaml\` - pnpm lockfile (for reproducible builds)" >> bundle-report/README.md
|
|
|
|
- name: Upload bundle analyzer reports
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: bundle-report-${{ github.run_id }}
|
|
path: bundle-report/
|
|
retention-days: 30
|
|
if-no-files-found: warn
|
|
|
|
- name: Create summary comment
|
|
run: |
|
|
echo "## Bundle Analysis Complete :chart_with_upwards_trend:" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Artifact:** \`bundle-report-${{ github.run_id }}\`" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "Download the artifact to view the detailed bundle analysis reports." >> $GITHUB_STEP_SUMMARY
|