Skip to content

Commit

Permalink
Merge pull request #1691 from hey-api/fix/publish-packages-turbo
Browse files Browse the repository at this point in the history
refactor: use Turbo to detect changed packages
  • Loading branch information
mrlubos authored Feb 9, 2025
2 parents bb504c5 + 3a5ea61 commit 1df55ed
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ jobs:

- name: Publish preview packages
if: github.event_name == 'pull_request' && matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
run: ./scripts/publish-preview-packages.sh ${{ github.event.pull_request.base.ref }}
run: ./scripts/publish-preview-packages.sh
env:
TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: pnpm build

- name: Create Release Pull Request
uses: changesets/action@v1
uses: changesets/action@v1.4.9
with:
publish: pnpm changeset publish
version: pnpm changeset version
Expand Down
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @hey-api/docs
# @docs/openapi-ts

## 0.10.0

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: home

hero:
name: High-quality tools for interacting with APIs
tagline: Codegen for your TypeScript projects. Trusted more than 700k times each month to generate reliable API clients and SDKs.
tagline: Codegen for your TypeScript projects. Trusted more than 800k times each month to generate reliable API clients and SDKs.
actions:
- link: /openapi-ts/get-started
text: Get Started
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi-ts/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { embedProject } from '../embed'
This package is in initial development. The interface might change before it becomes stable. We encourage you to leave feedback on [GitHub](https://github.com/hey-api/openapi-ts/issues).
:::

[@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts) is an OpenAPI to TypeScript codegen trusted more than 700k times each month to generate reliable API clients and SDKs. The code is [MIT-licensed](/license) and free to use. Discover available features below or view our [roadmap](https://github.com/orgs/hey-api/discussions/1495) to learn what's coming next.
[@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts) is an OpenAPI to TypeScript codegen trusted more than 800k times each month to generate reliable API clients and SDKs. The code is [MIT-licensed](/license) and free to use. Discover available features below or view our [roadmap](https://github.com/orgs/hey-api/discussions/1495) to learn what's coming next.

<button class="buttonLink" @click="(event) => embedProject('hey-api-example')(event)">
Live demo
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@hey-api/docs",
"name": "@docs/openapi-ts",
"version": "0.10.0",
"description": "Documentation for OpenaAPI TypeScript.",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"test:update": "turbo run test:update",
"test": "turbo run test",
"typecheck": "turbo run typecheck --filter=\"!@example/openapi-ts-sample\"",
"vitepress": "turbo run $1 --filter=\"@hey-api/docs\""
"vitepress": "turbo run $1 --filter=\"@docs/openapi-ts\""
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=22.11.0"
Expand Down
28 changes: 4 additions & 24 deletions scripts/publish-preview-packages.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
#!/bin/bash

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

BASE_BRANCH=$1
result=$(pnpx turbo run build --affected --dry-run=json)

# ensure we have the latest changes from the remote
git fetch origin
packages=$(echo "$result" | jq -r '.tasks[].directory' | grep '^packages/' | sed 's|^|./|')

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
if [ -n "$packages" ]; then
pnpx pkg-pr-new publish --pnpm $packages
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 1df55ed

Please sign in to comment.