-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (76 loc) · 3.34 KB
/
preview-cli-package.yml
File metadata and controls
90 lines (76 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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"