Skip to content

chore(main): release 2.0.1 #623

chore(main): release 2.0.1

chore(main): release 2.0.1 #623

Workflow file for this run

name: '📦 Package size'
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
pull-requests: write
jobs:
calculate-base:
runs-on: ubuntu-latest
outputs:
package_size: ${{ steps.package-base.outputs.package_size }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Get commit short hash
id: commit
run: |
short=$(git rev-parse --short HEAD)
echo "short=$short" >> "$GITHUB_OUTPUT"
- name: Setup Node ⚙️
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Cache Dependencies ⌛️
uses: 'actions/cache@v4'
id: cache-node-modules
with:
path: 'node_modules'
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies 📥
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: 📦 Cache package size for commit ${{ steps.commit.outputs.short }}
uses: actions/cache@v4
with:
path: base-package-size.txt
key: base-package-size-os-${{ runner.os }}-commit-${{ steps.commit.outputs.short }}
- name: 🎁 Calculate package size in ${{ github.base_ref }}
id: package-base
run: |
if [ -f base-package-size.txt ]; then
echo "Getting package size from cache"
package_size=$(<base-package-size.txt)
else
echo "Package size not available in the cache"
package_size=$(npm publish --dry-run 2>&1 | grep "unpacked size" | awk '{print $5 $6}')
fi
echo "$package_size" > base-package-size.txt
echo "package_size=$package_size" >> "$GITHUB_OUTPUT"
echo "Package size: $package_size"
calculate-head:
runs-on: ubuntu-latest
outputs:
package_size: ${{ steps.package-head.outputs.package_size }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Setup Node ⚙️
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Cache Dependencies ⌛️
uses: 'actions/cache@v4'
id: cache-node-modules
with:
path: 'node_modules'
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies 📥
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: 🎁 Calculate package size in ${{ github.head_ref }}
id: package-head
run: |
package_size=$(npm publish --dry-run 2>&1 | grep "unpacked size" | awk '{print $5 $6}')
echo "package_size=$package_size" >> "$GITHUB_OUTPUT"
echo "Package size: $package_size"
write-comment:
runs-on: ubuntu-latest
needs: [calculate-base, calculate-head]
steps:
- uses: marocchino/sticky-pull-request-comment@v2
env:
BASE_PACKAGE_SIZE: ${{needs.calculate-base.outputs.package_size}}
HEAD_PACKAGE_SIZE: ${{needs.calculate-head.outputs.package_size}}
with:
header: <package-size>
message: |
## 📦 Package Metrics 📦
* Size of the Package in the base (${{ github.base_ref }}): **${{ env.BASE_PACKAGE_SIZE }}**
* Size of the Package in this branch (${{ github.head_ref }}): **${{ env.HEAD_PACKAGE_SIZE }}**