@@ -235,40 +235,6 @@ jobs:
235235 if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
236236 LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest)
237237 LATEST=$(echo "$LATEST_RELEASE" | jq -r '.name')
238- # Check artifact sizes against previous release
239- if [ -n "$LATEST" ] && [ "$LATEST" != "null" ]; then
240- echo "Checking artifact sizes against previous release: $LATEST"
241- FAILED=0
242- for artifact in js-*-${VERSION}.*; do
243- if [ ! -f "$artifact" ]; then
244- continue
245- fi
246- # Get current artifact size
247- NEW_SIZE=$(stat -c%s "$artifact" 2>/dev/null || stat -f%z "$artifact")
248- # Get artifact name for previous release
249- ARTIFACT_NAME=$(echo "$artifact" | sed "s/${VERSION}/${LATEST}/")
250- # Get previous artifact size from GitHub API
251- OLD_SIZE=$(echo "$LATEST_RELEASE" | jq -r ".assets[] | select(.name == \"$(basename "$ARTIFACT_NAME")\") | .size")
252- if [ -z "$OLD_SIZE" ] || [ "$OLD_SIZE" = "null" ]; then
253- echo "⚠️ Previous artifact not found: $(basename "$ARTIFACT_NAME"), skipping comparison"
254- continue
255- fi
256- # Calculate percentage increase
257- INCREASE=$(awk "BEGIN {printf \"%.2f\", (($NEW_SIZE - $OLD_SIZE) / $OLD_SIZE) * 100}")
258- echo "📦 $artifact: $OLD_SIZE → $NEW_SIZE bytes (${INCREASE}% change)"
259- # Check if increase is more than 5%
260- if (( $(echo "$INCREASE > 5" | bc -l) )); then
261- echo "❌ ERROR: $artifact size increased by ${INCREASE}% (limit: 5%)"
262- FAILED=1
263- fi
264- done
265- if [ $FAILED -eq 1 ]; then
266- echo ""
267- echo "❌ One or more artifacts exceeded the 5% size increase limit"
268- exit 1
269- fi
270- echo "✅ All artifacts within 5% size increase limit"
271- fi
272238
273239 if [[ "$VERSION" != "$LATEST" || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
274240 echo "version=$VERSION" >> $GITHUB_OUTPUT
0 commit comments