diff --git a/.github/scripts/is_release_for_package.sh b/.github/scripts/is_release_for_package.sh new file mode 100755 index 0000000..c8965ef --- /dev/null +++ b/.github/scripts/is_release_for_package.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# This script checks if the specified package has changesets in the current commit. + +set -eu + +if [ $# -lt 1 ]; then + echo "Error: Package name is required as the first argument." >&2 + exit 1 +fi + +PACKAGE_NAME=$1 +PACKAGE_CHANGES=$(node -e "require('@changesets/read').default(process.cwd()).then(result => console.log(result.flatMap(changeset => changeset.releases.flatMap(release => release.name)).includes('${PACKAGE_NAME}')))") + +echo "${PACKAGE_CHANGES}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 00526d3..dd179cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,34 +54,45 @@ jobs: if: needs.is_release.outputs.release == 'true' runs-on: ubuntu-latest outputs: - js-sdk: ${{ steps.filter.outputs.js-sdk }} - python-sdk: ${{ steps.filter.outputs.python-sdk }} + js-sdk: ${{ steps.js.outputs.release }} + python-sdk: ${{ steps.python.outputs.release }} steps: - - name: Checkout repository + - name: Checkout Repo uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Get the last release - id: last_release - uses: cardinalby/git-get-release-action@v1 - env: - GITHUB_TOKEN: ${{ github.token }} + - name: Install pnpm + uses: pnpm/action-setup@v3 + id: pnpm-install with: - latest: true - prerelease: false - draft: false + version: 9.5 - - name: Find changes since the last release - uses: dorny/paths-filter@v2 - id: filter + - name: Setup Node + uses: actions/setup-node@v3 with: - base: ${{ steps.last_release.outputs.tag_name }} - filters: | - js-sdk: - - 'packages/js-sdk/**' - python-sdk: - - 'packages/python-sdk/**' + node-version: "18.x" + registry-url: "https://registry.npmjs.org" + cache: pnpm + cache-dependency-path: pnpm-lock.yaml + + - name: Configure pnpm + run: | + pnpm config set auto-install-peers true + pnpm config set exclude-links-from-lockfile true + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Check JavasScript SDK Release + id: js + run: | + IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/desktop") + echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT" + + - name: Check Python SDK Release + id: python + run: | + IS_RELEASE=$(./.github/scripts/is_release_for_package.sh "@e2b/desktop-python") + echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT" publish: name: Publish