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 474b5e0
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
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
2 changes: 2 additions & 0 deletions packages/client-fetch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ Automatically update your code when the APIs it depends on change. [Find out mor
## Migration Guides

[OpenAPI Typescript Codegen](https://heyapi.dev/openapi-ts/migrating.html#openapi-typescript-codegen)

sample change...
2 changes: 2 additions & 0 deletions packages/openapi-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,5 @@ The following plugins are planned but not in development yet. You can help us pr
## License

Released under the [MIT License](https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md).

sample change...
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

0 comments on commit 474b5e0

Please sign in to comment.