Skip to content

Commit d629549

Browse files
tuha263claude
andauthored
fix: Support workflow_dispatch for publishing all packages (#4)
- Add logic to detect trigger type (workflow_dispatch vs push) - When manually triggered, scan ALL package.json files instead of just changed ones - Supports specific package_path input or scans entire repository - Fixes issue where manual triggers failed with 'No package.json files changed' - Excludes node_modules and hidden directories from scan This allows manual publishing of unpublished packages without requiring version bump commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent 737d20e commit d629549

File tree

1 file changed

+46
-12
lines changed

1 file changed

+46
-12
lines changed

.github/workflows/publish-upm.yml

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
name: Publish to UPM Registry
22

33
on:
4-
workflow_dispatch: # Manual trigger
5-
64
push:
75
branches:
86
- master
97
- main
108
paths:
119
- '**/package.json'
1210

11+
# Allow manual trigger for publishing stale packages
12+
workflow_dispatch:
13+
inputs:
14+
package_path:
15+
description: 'Path to package.json (optional, e.g., Assets/MyPackage/package.json). Leave empty to publish all packages.'
16+
required: false
17+
type: string
18+
1319
# FIX ME-6: Explicit permissions for security and clarity
1420
permissions:
1521
contents: read # Read repository contents
@@ -23,12 +29,12 @@ jobs:
2329

2430
steps:
2531
- name: Checkout repository
26-
uses: actions/checkout@v4
32+
uses: actions/checkout@v5
2733
with:
2834
fetch-depth: 2 # Need previous commit for diff
2935

3036
- name: Setup Node.js
31-
uses: actions/setup-node@v4
37+
uses: actions/setup-node@v6
3238
with:
3339
node-version: '18'
3440
registry-url: 'https://upm.the1studio.org/'
@@ -160,18 +166,46 @@ jobs:
160166
echo "========================================="
161167
162168
echo "========================================="
163-
echo "🔍 Detecting changed package.json files"
169+
echo "🔍 Detecting package.json files to publish"
164170
echo "========================================="
165171
166-
# Get list of changed package.json files
167-
changed_files=$(git diff --name-only HEAD~1 HEAD | grep 'package\.json$' || true)
172+
# Detect trigger type and get appropriate file list
173+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
174+
echo "📋 Manual trigger detected (workflow_dispatch)"
168175
169-
if [ -z "$changed_files" ]; then
170-
echo "ℹ️ No package.json files changed in this commit"
171-
exit 0
176+
# Check if specific package_path was provided
177+
if [ -n "${{ inputs.package_path }}" ]; then
178+
echo "📌 Using specified package path: ${{ inputs.package_path }}"
179+
changed_files="${{ inputs.package_path }}"
180+
else
181+
echo "🔍 Scanning ALL package.json files in repository..."
182+
# Find all package.json files, excluding node_modules and hidden directories
183+
changed_files=$(find . -name "package.json" \
184+
-not -path "*/node_modules/*" \
185+
-not -path "*/.*/*" \
186+
-type f \
187+
| sed 's|^\./||' || true)
188+
189+
if [ -z "$changed_files" ]; then
190+
echo "❌ No package.json files found in repository"
191+
exit 1
192+
fi
193+
194+
echo "📦 Found $(echo "$changed_files" | wc -l) package.json files"
195+
fi
196+
else
197+
echo "🔄 Automatic trigger detected (push)"
198+
# Get list of changed package.json files from git diff
199+
changed_files=$(git diff --name-only HEAD~1 HEAD | grep 'package\.json$' || true)
200+
201+
if [ -z "$changed_files" ]; then
202+
echo "ℹ️ No package.json files changed in this commit"
203+
exit 0
204+
fi
172205
fi
173206
174-
echo "📦 Found changed package.json files:"
207+
echo ""
208+
echo "📦 Package.json files to process:"
175209
echo "$changed_files"
176210
echo ""
177211
@@ -543,7 +577,7 @@ jobs:
543577
# FIX L-4: Make audit log retention configurable
544578
- name: Upload audit log
545579
if: always()
546-
uses: actions/upload-artifact@v4
580+
uses: actions/upload-artifact@v5
547581
with:
548582
name: audit-log-${{ github.run_id }}
549583
path: audit-log.json

0 commit comments

Comments
 (0)