forked from prisma/prisma
-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (145 loc) · 5.38 KB
/
release-ci.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
name: npm - release to dev/integration
run-name: npm - release from ${{ github.ref_name }} to dev/integration
on:
push:
branches:
- main
- 'integration/*'
- '*.*.x'
paths-ignore:
# Any update here needs to be done for
# all files (test.yml, benchmark.yml, release-ci.yml, bundle-size.yml)
- '*.md'
- '*.bench.ts'
- 'LICENSE'
- '.dockerignore'
# - 'scripts/ci/publish.ts' -> should not be ignored in this workflow
- '.github/CODEOWNERS'
- '.github/renovate.json'
- '.github/ISSUE_TEMPLATE/**'
- '.github/DISCUSSION_TEMPLATE/**'
- '.devcontainer/**'
- '.vscode/**'
- 'graphs/**'
- 'sandbox/**'
workflow_dispatch:
inputs:
dryRun:
description: 'Check to do a dry run (does not publish packages)'
type: boolean
forceIntegrationRelease:
description: 'Check to force an integration release for any given branch name'
type: boolean
env:
# To hide "Update available 0.0.0 -> x.x.x"
PRISMA_HIDE_UPDATE_MESSAGE: 'true'
jobs:
release:
timeout-minutes: 75
# environment: 'npm-ci'
runs-on: ubuntu-latest
permissions:
# required for publishing to npm with --provenance
# see https://docs.npmjs.com/generating-provenance-statements
id-token: write
outputs:
prismaVersion: ${{ steps.publish.outputs.prismaVersion }}
steps:
- name: Print input
env:
THE_INPUT: '${{ toJson(github.event.inputs) }}'
run: |
echo "$THE_INPUT"
- uses: actions/checkout@v4
- name: Install & build
uses: ./.github/actions/setup
with:
node-version: 18
pnpm-version: 8.15.5
skip-tsc: false
- name: Publish all packages to npm
id: publish
run: pnpm run publish-all
env:
# Inputs
DRY_RUN: ${{ github.event.inputs.dryRun == 'true' && 'true' || '' }}
FORCE_INTEGRATION_RELEASE: ${{ github.event.inputs.forceIntegrationRelease == 'true' && 'true' || '' }}
# Other
BUILDKITE: true
BUILDKITE_BRANCH: ${{ github.ref_name }}
GITHUB_CONTEXT: ${{ toJson(github) }}
# https://docs.npmjs.com/generating-provenance-statements
NPM_CONFIG_PROVENANCE: true
# Secrets
# Note: must use personal access token
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
REDIS_URL: ${{ secrets.REDIS_URL }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
SLACK_RELEASE_FEED_WEBHOOK: ${{ secrets.SLACK_RELEASE_FEED_WEBHOOK }}
- name: Print output
env:
THE_OUTPUT: '${{ toJson(steps.publish.outputs) }}'
run: |
echo "$THE_OUTPUT"
# TODO de-duplicate (currently duplicated in release-*.yml)
# Docs https://octokit.github.io/rest.js/v20#git-create-tag
- name: Create a tag on prisma-engines repository
uses: actions/github-script@v7
id: tag-prisma-engines
env:
REPO_NAME: 'prisma-engines'
TAG_NAME: '${{ steps.publish.outputs.prismaVersion }}'
MESSAGE: '${{ steps.publish.outputs.changelogSanitized }}'
COMMIT_HASH: '${{ steps.publish.outputs.enginesCommitHash }}'
with:
result-encoding: string
github-token: ${{ secrets.BOT_TOKEN }}
script: |
const commitNewTag = await github.rest.git.createTag({
owner: 'prisma',
repo: '${{ env.REPO_NAME }}',
tag: '${{ env.TAG_NAME }}',
message: '${{ env.MESSAGE }}',
object: '${{ env.COMMIT_HASH }}',
type: 'commit',
})
await github.rest.git.createRef({
owner: 'prisma',
repo: '${{ env.REPO_NAME }}',
ref: `refs/tags/${{ env.TAG_NAME }}`,
sha: commitNewTag.data.sha,
})
# We also have `sendSlackMessage()` in publish.ts
# It uses the #feed-prisma-releases channel and adds more information
success:
needs:
- release
if: ${{ success() }}
name: Communicate success
runs-on: ubuntu-latest
steps:
- name: Set current job url in SLACK_FOOTER env var
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 Success
uses: rtCamp/[email protected]
env:
SLACK_TITLE: 'prisma/prisma Release ${{ needs.release.outputs.prismaVersion }} succeeded :white_check_mark:'
SLACK_COLOR: '#55ff55'
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_FEED_WEBHOOK }}
SLACK_CHANNEL: feed-prisma-publish
failure:
needs:
- release
if: ${{ failure() }}
name: Communicate failure
runs-on: ubuntu-latest
steps:
- name: Set current job url in SLACK_FOOTER env var
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
uses: rtCamp/[email protected]
env:
SLACK_TITLE: 'prisma/prisma Release from ${{ github.ref_name }} to dev/integration failed :x:'
SLACK_COLOR: '#FF0000'
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_FEED_WEBHOOK }}
SLACK_CHANNEL: feed-prisma-publish-failures