Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: publish only changed packages #1554

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ jobs:
os: [macos-latest, ubuntu-latest, windows-latest]
node-version: ['18.20.5', '20.11.1', '22.11.0']
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
fetch-depth: 0

- uses: pnpm/[email protected]

Expand Down Expand Up @@ -51,6 +53,6 @@ jobs:
- name: Run e2e tests
run: pnpm test:e2e

- name: Publish previews
- name: Publish preview packages
if: matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
run: pnpx pkg-pr-new publish --pnpm './packages/*'
run: ./scripts/publish-preview-packages.sh ${{ github.event.pull_request.base.ref }}
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
language: [javascript]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.2

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.2

- uses: pnpm/[email protected]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.2

- uses: pnpm/[email protected]

Expand Down
29 changes: 29 additions & 0 deletions scripts/publish-preview-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

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

BASE_BRANCH=$1

# ensure we have the latest changes from the remote
git fetch origin

if ! git show-ref --verify --quiet refs/remotes/origin/"$BASE_BRANCH"; then
echo "Error: Base branch '$BASE_BRANCH' not found in the remote repository."
exit 1
fi

echo "Detecting changed packages compared to $BASE_BRANCH..."
CHANGED_PACKAGES=$(git diff --name-only origin/"$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" | awk '{printf "./packages/%s ", $1}' | sed 's/ $//')

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