ci(cli): create release tags with GitHub API #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Preview CLI Package | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| concurrency: | |
| group: preview-cli-package-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| preview: | |
| if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| persist-credentials: false | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e | |
| with: | |
| node-version: 24 | |
| - name: Enable pnpm | |
| run: | | |
| corepack enable | |
| PNPM_VERSION="$(node -p 'const pm = require("./package.json").packageManager; const match = pm && pm.match(/^pnpm@(.+)$/); if (!match) throw new Error("packageManager must be pnpm@<version>"); match[1]')" | |
| corepack prepare "pnpm@${PNPM_VERSION}" --activate | |
| echo "PNPM_STORE_PATH=$(pnpm store path)" >> "$GITHUB_ENV" | |
| - name: Cache pnpm store | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 | |
| with: | |
| path: ${{ env.PNPM_STORE_PATH }} | |
| key: pnpm-store-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| restore-keys: | | |
| pnpm-store-${{ runner.os }}- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Resolve preview version | |
| id: cli_version | |
| run: | | |
| node scripts/resolve-cli-version.mjs pr \ | |
| --sha '${{ github.event.pull_request.head.sha }}' \ | |
| --pr-number '${{ github.event.pull_request.number }}' >> "$GITHUB_OUTPUT" | |
| - name: Run focused CLI tests | |
| id: cli_tests | |
| run: pnpm --filter @prisma/cli test | |
| - name: Build CLI package | |
| id: cli_build | |
| run: pnpm --filter @prisma/cli build | |
| - name: Prepare staged preview package | |
| id: prepare_preview | |
| run: node scripts/prepare-cli-publish.mjs .publish/cli --version '${{ steps.cli_version.outputs.version }}' | |
| - name: Publish installable PR preview | |
| id: publish_preview | |
| continue-on-error: ${{ vars.CLI_PR_PREVIEW_REQUIRED != 'true' }} | |
| run: pnpm exec pkg-pr-new publish --bin --comment=update .publish/cli | |
| - name: Summarize PR preview publish | |
| if: ${{ always() }} | |
| run: | | |
| { | |
| echo "## Preview CLI Package" | |
| echo | |
| echo "- Version: \`${{ steps.cli_version.outputs.version }}\`" | |
| echo "- CLI tests: \`${{ steps.cli_tests.outcome || 'skipped' }}\`" | |
| echo "- Build: \`${{ steps.cli_build.outcome || 'skipped' }}\`" | |
| echo "- Package staging: \`${{ steps.prepare_preview.outcome || 'skipped' }}\`" | |
| echo "- pkg.pr.new publish: \`${{ steps.publish_preview.outcome || 'skipped' }}\`" | |
| PUBLISH_OUTCOME="${{ steps.publish_preview.outcome || 'skipped' }}" | |
| if [ "${PUBLISH_OUTCOME}" != "success" ]; then | |
| echo | |
| echo "pkg.pr.new publishing is best-effort while \`CLI_PR_PREVIEW_REQUIRED\` is not \`true\`. If this failed, confirm the pkg.pr.new GitHub App is installed for this repository and rerun the workflow." | |
| fi | |
| } >> "$GITHUB_STEP_SUMMARY" |