mirror of
https://github.com/ant-design/ant-design-cli.git
synced 2026-09-14 19:07:15 +08:00
ae21dc4542
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56 lines
1.8 KiB
YAML
56 lines
1.8 KiB
YAML
name: Pkg Size
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
pkg-size:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version: 24
|
|
|
|
- run: npm ci
|
|
- run: npm run build
|
|
|
|
- name: Get pack size
|
|
id: size
|
|
run: |
|
|
PACK=$(npm pack --dry-run --json 2>&1 | sed -n '/^\[/,/^\]/p' | jq '.[0]')
|
|
echo "size=$(echo "$PACK" | jq '.size')" >> "$GITHUB_OUTPUT"
|
|
echo "unpack_size=$(echo "$PACK" | jq '.unpackedSize')" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Get base branch size
|
|
if: github.event_name == 'pull_request'
|
|
id: base_size
|
|
run: |
|
|
git fetch origin ${{ github.base_ref }} --depth=1
|
|
git checkout FETCH_HEAD -- . 2>/dev/null || true
|
|
npm ci
|
|
npm run build
|
|
PACK=$(npm pack --dry-run --json 2>&1 | sed -n '/^\[/,/^\]/p' | jq '.[0]')
|
|
echo "size=$(echo "$PACK" | jq '.size')" >> "$GITHUB_OUTPUT"
|
|
echo "unpack_size=$(echo "$PACK" | jq '.unpackedSize')" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Comment on PR
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const run = require('./scripts/pkg-size-comment.cjs');
|
|
await run({
|
|
github, context,
|
|
size: parseInt('${{ steps.size.outputs.size }}'),
|
|
unpackSize: parseInt('${{ steps.size.outputs.unpack_size }}'),
|
|
baseSize: parseInt('${{ steps.base_size.outputs.size }}') || parseInt('${{ steps.size.outputs.size }}'),
|
|
baseUnpackSize: parseInt('${{ steps.base_size.outputs.unpack_size }}') || parseInt('${{ steps.size.outputs.unpack_size }}'),
|
|
});
|