Skip to content

Commit

Permalink
ci: publish only changed packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Jan 12, 2025
1 parent 9c9e9c5 commit c9bbf69
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ jobs:

- name: Publish previews
if: matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
run: pnpx pkg-pr-new publish --pnpm './packages/*'
run: ../scripts/publish-previews.sh ${{ github.event.pull_request.base.ref }}
23 changes: 23 additions & 0 deletions scripts/publish-previews.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "Error: Base branch not specified. Usage: publish-previews.sh <base-branch>"
exit 1
fi

BASE_BRANCH=$1

echo "Detecting changed packages compared to $BASE_BRANCH..."
CHANGED_PACKAGES=$(git diff --name-only "$BASE_BRANCH"...HEAD | grep '^packages/' | cut -d '/' -f 2 | sort -u)

if [ -z "$CHANGED_PACKAGES" ]; then
echo "No changed packages detected."
exit 0
fi

PACKAGE_PATHS=$(echo $CHANGED_PACKAGES | sed "s/^/packages\//g")

echo "Publishing changed packages: $PACKAGE_PATHS"
# pnpx pkg-pr-new publish --pnpm $PACKAGE_PATHS

# pnpx pkg-pr-new publish --pnpm './packages/*'

0 comments on commit c9bbf69

Please sign in to comment.