-
Notifications
You must be signed in to change notification settings - Fork 2
91 lines (82 loc) · 3.13 KB
/
release.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
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Changesets Release
# Prevents action from creating a PR on forks
if: github.repository == 'apollographql/graphql-testing-library'
runs-on: ubuntu-latest
# Permissions necessary for Changesets to push a new branch and open PRs
# (for automated Version Packages PRs), and request the JWT 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
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
# Fetch entire git history so Changesets can generate changelogs
# with the correct commits
fetch-depth: 0
- name: Check for pre.json file existence
id: check_files
uses: andstor/[email protected]
with:
files: ".changeset/pre.json"
- name: Append NPM token to .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
provenance=true
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install pnpm and dependencies
uses: pnpm/action-setup@v4
with:
version: 9
run_install: true
- name: Create release PR or publish to npm + GitHub
id: changesets
if: steps.check_files.outputs.files_exists == 'false'
uses: changesets/action@v1
with:
version: pnpm run changeset-version
publish: pnpm run changeset-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Send a Slack notification on publish
if: steps.changesets.outcome == 'success' && steps.changesets.outputs.published == 'true'
id: slack
uses: slackapi/[email protected]
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: "C07K7QQ93FW"
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "A new version of `@apollo/graphql-testing-library` was released: <https://github.com/apollographql/graphql-testing-library/releases/tag/v${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}|v${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}> :rocket:"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}