-
Notifications
You must be signed in to change notification settings - Fork 2.9k
182 lines (167 loc) · 7.23 KB
/
Copy pathrelease.yml
File metadata and controls
182 lines (167 loc) · 7.23 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
name: Release
on:
push:
branches:
- main
- version-3.x
- "release-*"
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions: {}
jobs:
release:
name: Changesets Release
# Prevents action from creating a PR on forks
if: github.repository == 'apollographql/apollo-client'
runs-on: ubuntu-latest
# Permissions necessary for Changesets to push a new branch and open PRs
# (for automated Version Packages PRs), and request an id-token for provenance.
# More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
permissions:
contents: write
pull-requests: write
id-token: write
outputs:
published: ${{ steps.changesets.outputs.published || steps.changesets-prerelease.outputs.published }}
publishedPackages: ${{ steps.changesets.outputs.publishedPackages || steps.changesets-prerelease.outputs.publishedPackages }}
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
# Fetch entire git history so Changesets can generate changelogs
# with the correct commits
fetch-depth: 0
persist-credentials: false
- name: Check for pre.json file existence
id: check_files
uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
with:
files: ".changeset/pre.json"
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: "24.x"
registry-url: "https://registry.npmjs.org"
# deliberately not using a cache for action with elevated permissions, see https://tanstack.com/blog/npm-supply-chain-compromise-postmortem
package-manager-cache: false
- run: npm ci
- name: "[main] Create release PR or publish to npm + GitHub"
id: changesets
if: contains(fromJSON('["main", "version-3.x"]'), github.ref_name) && steps.check_files.outputs.files_exists == 'false'
uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1
with:
version: npm run changeset-version
publish: npm run changeset-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ""
- name: "[prerelease] Publish to npm + GitHub"
id: changesets-prerelease
# Only run publish if we're still in pre mode and the last commit was
# via an automatically created Version Packages PR
if: github.ref_name != 'main' && github.ref_name != 'version-3.x' && steps.check_files.outputs.files_exists == 'true' && startsWith(github.event.head_commit.message, 'Version Packages')
uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1
with:
version: echo "This step should never version"
publish: npm run changeset-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ""
slack-notification:
name: Postrelease Slack Notification
runs-on: ubuntu-latest
needs: release
if: needs.release.result == 'success' && needs.release.outputs.published == 'true'
strategy:
matrix:
package: ${{ fromJSON(needs.release.outputs.publishedPackages) }}
steps:
- name: Send a Slack notification on publish
id: slack
uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3
with:
# Slack channel id, channel name, or user id to post message
# See also: https://api.slack.com/methods/chat.postMessage#channels
# You can pass in multiple channels to post to by providing
# a comma-delimited list of channel IDs
channel-id: "C01PS0CB41G"
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "A new version of `{{ matrix.package.name }}` was released :rocket:"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Version:*\n`${{ matrix.package.version }}`"
},
{
"type": "mrkdwn",
"text": "*Tag:*\n`${{ github.ref_name == 'main' && 'latest' || 'next' }}`"
},
{
"type": "mrkdwn",
"text": "*GitHub release:*\n<https://github.com/apollographql/apollo-client/releases/tag/${{ matrix.package.name }}@${{ matrix.package.version }}|link>"
},
{
"type": "mrkdwn",
"text": "*npm releases:*\n<https://www.npmjs.com/package/@apollo/client?activeTab=versions|link>"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
tag-next:
name: Postrelease Tag Next Release
runs-on: ubuntu-latest
needs: release
if: github.ref_name != 'main' && github.ref_name != 'version-3.x' && needs.release.result == 'success' && needs.release.outputs.published == 'true'
permissions:
id-token: write
strategy:
matrix:
package: ${{ fromJSON(needs.release.outputs.publishedPackages) }}
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: "24.x"
registry-url: "https://registry.npmjs.org"
# deliberately not using a cache for action with elevated permissions, see https://tanstack.com/blog/npm-supply-chain-compromise-postmortem
package-manager-cache: false
- run: npm ci
- name: Tag release with next on npm
run: |
if NEXT=$(npm show ${{ matrix.package.name }}@next version) node -e 'process.exit(require("semver").gt("${{ matrix.package.version }}",process.env.NEXT)?0:1)'; then
npm dist-tag add ${{ matrix.package.name }}@${{ matrix.package.version }} next;
fi
devtools-errorcodes:
name: Trigger Devtools Error Code Update
needs: release
if: needs.release.result == 'success' && needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
permissions: {}
steps:
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 #v3
id: github-actions-bot-app-token
with:
app-id: 819772
private-key: ${{ secrets.APOLLO_GITHUB_ACTIONS_BOT_PRIVATE_KEY }}
repositories: apollo-client-devtools
- uses: benc-uk/workflow-dispatch@7a027648b88c2413826b6ddd6c76114894dc5ec4 #v1
with:
workflow: update-errorcodes.yml
repo: apollographql/apollo-client-devtools
token: ${{ steps.github-actions-bot-app-token.outputs.token }}