-
Notifications
You must be signed in to change notification settings - Fork 52
330 lines (318 loc) 路 11.7 KB
/
Copy pathrelease.yml
File metadata and controls
330 lines (318 loc) 路 11.7 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
name: Release
run-name: "Release ${{ github.event_name == 'push' && 'insider (push to main)' || format('{0} from {1}', inputs.channel, inputs.ref || 'main') }}"
# The single publishing pipeline for both the insider and the stable extension.
#
# - A push to main publishes an insider release.
# - A manual dispatch publishes an insider or stable release, optionally from
# an x.y.x patch branch (`ref`).
#
# This workflow never writes to the repository. The next extension version is
# derived from the git release tags (`x.y.z` for stable, `insider/x.y.z` for
# insider), and Prisma CLI dependency updates are a separate workflow
# (bump_prisma.yml) that commits to main. Only the `release` job holds write
# access, to create the tag and GitHub release.
on:
push:
branches:
- main
paths-ignore:
- '.github/**'
workflow_dispatch:
inputs:
channel:
description: 'Release channel'
required: true
type: choice
options:
- insider
- stable
default: insider
ref:
description: 'Branch to release from. Defaults to main. Use an x.y.x branch to patch an older version.'
required: false
bump:
description: 'Extension version bump (stable only; insider is always a patch)'
required: false
type: choice
options:
- patch
- minor
- major
default: patch
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: read
env:
ENVIRONMENT: ${{ secrets.ENVIRONMENT }}
PRISMA_TELEMETRY_INFORMATION: 'language-tools release.yml'
NODE_VERSION: '24'
jobs:
plan:
name: Plan release
if: github.repository == 'prisma/language-tools'
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
channel: ${{ steps.params.outputs.channel }}
ref: ${{ steps.params.outputs.ref }}
sha: ${{ steps.sha.outputs.sha }}
version: ${{ steps.version.outputs.version }}
tag_name: ${{ steps.version.outputs.tag_name }}
asset_name: ${{ steps.version.outputs.asset_name }}
npm_channel: ${{ steps.version.outputs.npm_channel }}
ls_npm_tag: ${{ steps.version.outputs.ls_npm_tag }}
steps:
- name: Resolve channel and branch
id: params
env:
EVENT_NAME: ${{ github.event_name }}
WORKFLOW_REF: ${{ github.ref }}
PUSH_SHA: ${{ github.sha }}
INPUT_CHANNEL: ${{ inputs.channel }}
INPUT_REF: ${{ inputs.ref }}
run: |
if [ "$EVENT_NAME" = "push" ]; then
CHANNEL=insider
REF="$PUSH_SHA"
else
if [ "$WORKFLOW_REF" != "refs/heads/main" ]; then
echo "Refusing to release from workflow ref '$WORKFLOW_REF'. Marketplace authentication is federated to main." >&2
exit 1
fi
CHANNEL="$INPUT_CHANNEL"
REF="${INPUT_REF:-main}"
case "$REF" in
main) ;;
*)
if ! echo "$REF" | grep -Eq '^[0-9]+\.[0-9]+\.x$'; then
echo "Refusing to release from '$REF'. Releases run from main or an x.y.x patch branch." >&2
exit 1
fi
;;
esac
fi
{
echo "channel=$CHANNEL"
echo "ref=$REF"
} >> "$GITHUB_OUTPUT"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ steps.params.outputs.ref }}
fetch-depth: 0 # all branches and tags: the next version is derived from release tags
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- name: Compute next extension version
id: version
env:
CHANNEL: ${{ steps.params.outputs.channel }}
BUMP: ${{ inputs.bump || 'patch' }}
run: node scripts/next_extension_version.mjs "$CHANNEL" "$BUMP"
- name: Resolve release commit
id: sha
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
test:
name: Test (${{ matrix.os }})
needs: [plan]
runs-on: ${{ matrix.os }}
timeout-minutes: 25
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- name: Build all packages
run: pnpm build
- name: Typecheck all packages
run: pnpm typecheck
- name: Run Language Server tests
run: pnpm --filter @prisma/language-server test
- name: Headless E2E tests
uses: coactions/setup-xvfb@b6b4fcfb9f5a895edadc3bc76318fae0ac17c8b3 # v1.0.1
with:
run: pnpm test:e2e
publish-language-server:
name: Publish Language Server to npm
needs: [plan, test]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
id-token: write
env:
NPM_CHANNEL: ${{ needs.plan.outputs.npm_channel }}
VERSION: ${{ needs.plan.outputs.version }}
LS_NPM_TAG: ${{ needs.plan.outputs.ls_npm_tag }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- name: Set Language Server version
run: node scripts/update_package_json_files.mjs "$NPM_CHANNEL" "$VERSION"
- name: Build Language Server
run: pnpm --filter @prisma/language-server build
- name: Publish Language Server to npm
run: pnpm --filter @prisma/language-server publish --tag "$LS_NPM_TAG" --access public --no-git-checks
package:
name: Build extension
needs: [plan, test]
runs-on: ubuntu-latest
timeout-minutes: 10
env:
CHANNEL: ${{ needs.plan.outputs.channel }}
NPM_CHANNEL: ${{ needs.plan.outputs.npm_channel }}
VERSION: ${{ needs.plan.outputs.version }}
ASSET_FILE: ${{ needs.plan.outputs.asset_name }}-${{ needs.plan.outputs.version }}.vsix
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- name: Set extension name and version
run: node scripts/update_package_json_files.mjs "$NPM_CHANNEL" "$VERSION"
- name: Replace Readme for marketplace
run: node scripts/change_readme.mjs "$CHANNEL"
- name: Build all packages
run: pnpm build
- name: Build vsix
run: cd packages/vscode && pnpm package
- name: Upload vsix as workflow artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: vsix
path: packages/vscode/${{ env.ASSET_FILE }}
if-no-files-found: error
release:
name: Create GitHub release
needs: [plan, package]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
env:
CHANNEL: ${{ needs.plan.outputs.channel }}
TAG_NAME: ${{ needs.plan.outputs.tag_name }}
ASSET_FILE: ${{ needs.plan.outputs.asset_name }}-${{ needs.plan.outputs.version }}.vsix
SHA: ${{ needs.plan.outputs.sha }}
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
steps:
- name: Download vsix artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: vsix
- name: Create GitHub release
run: |
PRERELEASE=""
if [ "$CHANNEL" = "insider" ]; then PRERELEASE="--prerelease"; fi
gh release create "$TAG_NAME" "$ASSET_FILE" \
--title "$TAG_NAME" \
--target "$SHA" \
$PRERELEASE
publish-marketplace:
name: Publish to VS Code Marketplace
needs: [plan, release]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
id-token: write # Required by azure/login and vsce --azure-credential.
env:
ASSET_FILE: ${{ needs.plan.outputs.asset_name }}-${{ needs.plan.outputs.version }}.vsix
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- name: Download vsix artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: vsix
- name: Log in to Azure
uses: azure/login@7ddb5af1ef8758cf1353cf3b42f940aee27ba21c # v3.0.2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: Publish vsix to marketplace
run: >-
cd packages/vscode && npx vsce publish --azure-credential --packagePath "$GITHUB_WORKSPACE/$ASSET_FILE"
publish-open-vsx:
name: Publish to open-vsx
needs: [plan, release]
runs-on: ubuntu-latest
timeout-minutes: 10
env:
ASSET_FILE: ${{ needs.plan.outputs.asset_name }}-${{ needs.plan.outputs.version }}.vsix
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.plan.outputs.sha }}
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install
- name: Download vsix artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: vsix
- name: Publish vsix to open-vsx.org
env:
OVSX_PAT: ${{ secrets.OPEN_VSX_ACCESS_TOKEN }}
run: >-
cd packages/vscode && npx ovsx --debug publish "$GITHUB_WORKSPACE/$ASSET_FILE"