mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 02:44:45 +00:00
refactor: simplify version check logic in publish workflow
This commit is contained in:
24
.github/workflows/publish.yaml
vendored
24
.github/workflows/publish.yaml
vendored
@@ -34,25 +34,21 @@ jobs:
|
|||||||
- name: Build & Test
|
- name: Build & Test
|
||||||
run: pnpm build && pnpm test
|
run: pnpm build && pnpm test
|
||||||
|
|
||||||
- name: Get changed files
|
|
||||||
id: changed-files
|
|
||||||
uses: tj-actions/changed-files@v46
|
|
||||||
with:
|
|
||||||
files: packages/*/package.json
|
|
||||||
|
|
||||||
- name: Check for version changes and publish
|
- name: Check for version changes and publish
|
||||||
if: steps.changed-files.outputs.any_changed == 'true'
|
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
# Find all package.json files (excluding node_modules)
|
||||||
|
PACKAGE_FILES=$(find . -path "*/package.json" -not -path "*/node_modules/*")
|
||||||
|
|
||||||
|
for file in $PACKAGE_FILES; do
|
||||||
PACKAGE_DIR=$(dirname $file)
|
PACKAGE_DIR=$(dirname $file)
|
||||||
echo "Checking $PACKAGE_DIR for version changes..."
|
echo "Checking $PACKAGE_DIR for version changes..."
|
||||||
|
|
||||||
# Get package details
|
# Get package details
|
||||||
PACKAGE_NAME=$(node -p "require('./$file').name")
|
PACKAGE_NAME=$(node -p "require('$file').name")
|
||||||
CURRENT_VERSION=$(node -p "require('./$file').version")
|
CURRENT_VERSION=$(node -p "require('$file').version")
|
||||||
IS_PRIVATE=$(node -p "require('./$file').private || false")
|
IS_PRIVATE=$(node -p "require('$file').private || false")
|
||||||
|
|
||||||
# Skip private packages
|
# Skip private packages
|
||||||
if [ "$IS_PRIVATE" == "true" ]; then
|
if [ "$IS_PRIVATE" == "true" ]; then
|
||||||
@@ -60,6 +56,12 @@ jobs:
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Skip root package
|
||||||
|
if [ "$PACKAGE_DIR" == "." ]; then
|
||||||
|
echo "Skipping root package"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if package exists on npm
|
# Check if package exists on npm
|
||||||
NPM_VERSION=$(npm view $PACKAGE_NAME version 2>/dev/null || echo "0.0.0")
|
NPM_VERSION=$(npm view $PACKAGE_NAME version 2>/dev/null || echo "0.0.0")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user