-
Notifications
You must be signed in to change notification settings - Fork 173
180 lines (166 loc) · 5.56 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
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
name: Release
on:
push:
branches:
- main
- releases/*
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
jobs:
release:
name: Release
if: github.repository == 'strapi/design-system'
runs-on: ubuntu-latest
outputs:
published_packages: ${{ steps.changesets.outputs.publishedPackages }}
published: ${{ steps.changesets.outputs.published }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: 'Restore cache'
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Install deps
run: yarn install
- name: Build
run: yarn build --filter=\!@strapi/design-system-docs
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
version: yarn release:version
publish: yarn release:publish
commit: 'chore: version packages for release'
title: 'chore: version packages for release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
find_package_version:
name: Find Package Versions
needs: [release]
runs-on: ubuntu-latest
if: github.repository == 'strapi/design-system' && needs.release.outputs.published == 'true'
outputs:
package_version: ${{ steps.find_package_version.outputs.package_version }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- id: find_package_version
run: |
package_version=$(node ./scripts/find-release-from-changeset.js)
echo "package_version=${package_version}" >> $GITHUB_OUTPUT
env:
PACKAGE_VERSION_TO_FOLLOW: '@strapi/design-system'
PUBLISHED_PACKAGES: ${{ needs.release.outputs.published_packages }}
notify_slack:
name: 'Notify Slack'
needs: [release, find_package_version]
runs-on: ubuntu-latest
if: github.repository == 'strapi/design-system' && needs.release.outputs.published == 'true'
steps:
- name: send message to slack
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Version ${{ needs.find_package_version.outputs.package_version }} has been successfuly deployed :tada:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Checkout the *<https://github.com/strapi/design-system/releases|release note>*"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://github.com/${{ github.triggering_actor }}.png",
"alt_text": "${{ github.triggering_actor }} avatar"
},
{
"type": "mrkdwn",
"text": "Triggered by *${{ github.triggering_actor }}*"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
notify_on_error:
needs: [release]
name: notify on error
runs-on: ubuntu-latest
if: failure()
steps:
- name: send message to slack
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Deployment failed or has been rejected :disappointed:",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Click here to see the logs>"
}
]
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://github.com/${{ github.triggering_actor }}.png",
"alt_text": "${{ github.triggering_actor }} avatar"
},
{
"type": "mrkdwn",
"text": "Triggered by *${{ github.triggering_actor }}*"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_RELEASE_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK