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 9d882d0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
- name: Build packages
run: pnpm --filter './packages/**' run build

- name: Publish previews
if: matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
run: ./scripts/publish-previews.sh ${{ github.event.pull_request.base.ref }}

- name: Build examples
if: matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
run: pnpm --filter './examples/**' run build
Expand All @@ -51,6 +55,6 @@ jobs:
- name: Run e2e tests
run: pnpm test:e2e

- name: Publish previews
if: matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
run: pnpx pkg-pr-new publish --pnpm './packages/*'
# - name: Publish previews
# if: matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
# 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 9d882d0

Please sign in to comment.