-
Notifications
You must be signed in to change notification settings - Fork 1.6k
232 lines (215 loc) · 11.4 KB
/
update-engines-version.yml
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
name: Update Engines Version
run-name: Update Engines on npm ${{ inputs.npmDistTag }} ${{ inputs.version }}
on:
workflow_dispatch:
inputs:
version:
description: 'Version to check and update the engines version'
required: true
npmDistTag:
description: 'npm tag used for `@prisma/engines-version` in prisma/engines-wrapper repo (`latest` or `integration` or `patch`)'
required: true
type: choice
options:
- latest
- integration
- patch
jobs:
update_engines:
name: 'Check and update @prisma/engines-version@${{ github.event.inputs.version }}'
runs-on: ubuntu-latest
steps:
- name: Print workflow_dispatch input
env:
THE_INPUT: '${{ toJson(github.event.inputs) }}'
run: |
echo $THE_INPUT
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.4.0
with:
version: 8
- uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: '16'
# This step uses `@prisma/ensure-npm-release` (abbv. `enr`) https://github.com/prisma/ensure-npm-release
- name: Check if version of @prisma/engines-version is available on npm
run: |
echo 'Checking that @prisma/engines-version have the published version @${{ github.event.inputs.version }}'
pnpm --package=@prisma/ensure-npm-release dlx enr update -p @prisma/engines-version -u ${{ github.event.inputs.version }}
# Note: @prisma/prisma-schema-wasm might take a few minutes before it's available
# So expect to see a few automated retries happening in logs before it succeeds
- name: Check if version of @prisma/prisma-schema-wasm is available on npm
run: |
echo 'Checking that @prisma/prisma-schema-wasm have the published version @${{ github.event.inputs.version }}'
pnpm --package=@prisma/ensure-npm-release dlx enr update -p @prisma/prisma-schema-wasm -u ${{ github.event.inputs.version }}
# Note: @prisma/query-engine-wasm might take a few minutes before it's available too
- name: Check if version of @prisma/query-engine-wasm is available on npm
run: |
echo 'Checking that @prisma/query-engine-wasm have the published version @${{ github.event.inputs.version }}'
pnpm --package=@prisma/ensure-npm-release dlx enr update -p @prisma/query-engine-wasm -u ${{ github.event.inputs.version }}
- name: Update the dependencies (@prisma/engines-version)
uses: nick-fields/retry@v2
with:
timeout_minutes: 7
max_attempts: 3
command: |
echo 'Updating @prisma/engines-version to ${{ github.event.inputs.version }} using pnpm'
pnpm update -r @prisma/engines-version@${{ github.event.inputs.version }}
- name: Update the dependencies (@prisma/prisma-schema-wasm)
uses: nick-fields/retry@v2
with:
timeout_minutes: 7
max_attempts: 3
command: |
echo 'Updating @prisma/prisma-schema-wasm to ${{ github.event.inputs.version }} using pnpm'
pnpm update -r @prisma/prisma-schema-wasm@${{ github.event.inputs.version }}
- name: Update the dependencies (@prisma/query-engine-wasm)
uses: nick-fields/retry@v2
with:
timeout_minutes: 7
max_attempts: 3
command: |
echo 'Updating @prisma/query-engine-wasm to ${{ github.event.inputs.version }} using pnpm'
pnpm update -r @prisma/query-engine-wasm@${{ github.event.inputs.version }}
- name: Extract Engine Commit hash from version
id: extract-engine-commit-hash
uses: actions/github-script@v7
with:
script: |
const hash = context.payload.inputs.version.split('.').pop()
core.setOutput('hash', hash)
#
# Regular engines PR, from prisma-engines main branch
# Will be automerged if tests are passing
#
- name: Create Pull Request
id: cpr
if: github.event.inputs.npmDistTag == 'latest'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.BOT_TOKEN }}
commit-message: 'chore(deps): update engines to ${{ github.event.inputs.version }}'
committer: 'Prismo <prismabots@gmail.com>'
author: 'Prismo <prismabots@gmail.com>'
branch: deps/engines-${{ github.event.inputs.version }}
delete-branch: true
labels: automerge
title: 'chore(deps): update engines to ${{ github.event.inputs.version }}'
body: |
The base branch for this PR is: main
This automatic PR updates the engines to version `${{ github.event.inputs.version }}`.
This will get automatically merged if all the tests pass.
:warning: If this PR needs to be updated, first remove the `automerge` label before pushing to avoid automerge to merge without waiting for tests.
## Packages
| Package | NPM URL |
|---------|---------|
|`@prisma/engines-version`| https://npmjs.com/package/@prisma/engines-version/v/${{ github.event.inputs.version }}|
|`@prisma/prisma-schema-wasm`| https://npmjs.com/package/@prisma/prisma-schema-wasm/v/${{ github.event.inputs.version }}|
|`@prisma/query-engine-wasm`| https://npmjs.com/package/@prisma/query-engine-wasm/v/${{ github.event.inputs.version }}|
## Engines commit
[`prisma/prisma-engines@${{ steps.extract-engine-commit-hash.outputs.hash }}`](https://github.com/prisma/prisma-engines/commit/${{ steps.extract-engine-commit-hash.outputs.hash }})
- name: PR url
if: github.event.inputs.npmDistTag == 'latest'
run: |
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: Sleep for 5 seconds
if: github.event.inputs.npmDistTag == 'latest'
run: sleep 5s
shell: bash
- name: Auto approve Pull Request (to trigger automerge if tests passing)
if: github.event.inputs.npmDistTag == 'latest' && steps.cpr.outputs.pull-request-operation == 'created'
uses: juliangruber/approve-pull-request-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.cpr.outputs.pull-request-number }}
#
# Integration Engine PR for end to end testing (From prisma/prisma-engines to prisma/prisma and finally npm)
# This will create a draft PR as we don't want to merge it
# But we want to publish it to npm
# For that we can create an `integration/` branch
#
- name: Create Pull Request for Integration Engine
id: cpr-integration
if: github.event.inputs.npmDistTag == 'integration'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.BOT_TOKEN }}
commit-message: 'chore(deps): update engines to ${{ github.event.inputs.version }}'
committer: 'Prismo <prismabots@gmail.com>'
author: 'Prismo <prismabots@gmail.com>'
branch: integration/engines-${{ github.event.inputs.version }}
delete-branch: true
draft: true
title: 'chore(Automated Integration PR): update engines to ${{ github.event.inputs.version }}'
body: |
The base branch for this PR is: main
This automatic integration PR updates the engines to version `${{ github.event.inputs.version }}`.
:warning: This PR should normally not be merged.
## Packages
| Package | NPM URL |
|---------|---------|
|`@prisma/engines-version`| https://npmjs.com/package/@prisma/engines-version/v/${{ github.event.inputs.version }}|
|`@prisma/prisma-schema-wasm`| https://npmjs.com/package/@prisma/prisma-schema-wasm/v/${{ github.event.inputs.version }}|
|`@prisma/query-engine-wasm`| https://npmjs.com/package/@prisma/query-engine-wasm/v/${{ github.event.inputs.version }}|
## Engines commit
[`prisma/prisma-engines@${{ steps.extract-engine-commit-hash.outputs.hash }}`](https://github.com/prisma/prisma-engines/commit/${{ steps.extract-engine-commit-hash.outputs.hash }})
- name: PR url
if: github.event.inputs.npmDistTag == 'integration'
run: |
echo "Pull Request URL - ${{ steps.cpr-integration.outputs.pull-request-url }}"
#
# Patch Engine PR, from a prisma-engines patch branch (e.g. "4.6.x")
# This will create a PR that will need to be manually merged
#
- name: Extract patch branch name from version
id: extract-patch-branch-name
uses: actions/github-script@v7
with:
script: |
const parts = context.payload.inputs.version.split('.')
const patchBranch = `${parts[0]}.${parts[1]}.x`
console.log(`patchBranch: ${patchBranch}`)
core.setOutput('patchBranch', patchBranch)
- name: Create Pull Request for Patch Engine
id: cpr-patch
if: github.event.inputs.npmDistTag == 'patch'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.BOT_TOKEN }}
commit-message: 'chore(deps): update engines to ${{ github.event.inputs.version }}'
committer: 'Prismo <prismabots@gmail.com>'
author: 'Prismo <prismabots@gmail.com>'
base: ${{ steps.extract-patch-branch-name.outputs.patchBranch }}
branch: patch/${{ github.event.inputs.version }}
title: 'chore(deps): patch ${{ steps.extract-patch-branch-name.outputs.patchBranch }} ${{ github.event.inputs.version }}'
body: |
The base branch for this PR is: ${{ steps.extract-patch-branch-name.outputs.patchBranch }}
This automatic PR updates the engines to version `${{ github.event.inputs.version }}`.
This PR will need to be manually merged (no auto-merge).
## Packages
| Package | NPM URL |
|---------|---------|
|`@prisma/engines-version`| https://npmjs.com/package/@prisma/engines-version/v/${{ github.event.inputs.version }}|
|`@prisma/prisma-schema-wasm`| https://npmjs.com/package/@prisma/prisma-schema-wasm/v/${{ github.event.inputs.version }}|
|`@prisma/query-engine-wasm`| https://npmjs.com/package/@prisma/query-engine-wasm/v/${{ github.event.inputs.version }}|
## Engines commit
[`prisma/prisma-engines@${{ steps.extract-engine-commit-hash.outputs.hash }}`](https://github.com/prisma/prisma-engines/commit/${{ steps.extract-engine-commit-hash.outputs.hash }})
- name: PR url
if: github.event.inputs.npmDistTag == 'patch'
run: |
echo "Pull Request URL - ${{ steps.cpr-patch.outputs.pull-request-url }}"
- name: 'Set current job url in SLACK_FOOTER env var'
if: ${{ failure() }}
run: echo "SLACK_FOOTER=<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID|Click here to go to the job logs>" >> $GITHUB_ENV
- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2.2.1
env:
SLACK_TITLE: 'Update Engines Version failed :x:'
SLACK_COLOR: '#FF0000'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: feed-prisma-failures
SLACK_USERNAME: Prismo
SLACK_ICON_EMOJI: ':boom:'
SLACK_MSG_AUTHOR: prisma-bot