-
Notifications
You must be signed in to change notification settings - Fork 480
200 lines (171 loc) · 5.44 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
jobs:
is_release:
name: Is release?
runs-on: ubuntu-latest
outputs:
release: ${{ steps.version.outputs.release }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 9.5
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Configure pnpm
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check if new version
id: version
run: |
IS_RELEASE=$(./.github/scripts/is_release.sh)
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
changes:
name: Repository changes
needs: [is_release]
if: needs.is_release.outputs.release == 'true'
runs-on: ubuntu-latest
outputs:
js-sdk: ${{ steps.filter.outputs.js-sdk }}
python-sdk: ${{ steps.filter.outputs.python-sdk }}
cli: ${{ steps.filter.outputs.cli }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get the last release
id: last_release
uses: cardinalby/git-get-release-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
latest: true
prerelease: false
draft: false
- name: Find changes since the last release
uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ steps.last_release.outputs.tag_name }}
filters: |
js-sdk:
- 'packages/js-sdk/**'
- '.github/workflows/js_sdk_tests.yml'
python-sdk:
- 'packages/python-sdk/**'
- '.github/workflows/python_sdk_tests.yml'
cli:
- 'packages/cli/**'
- '.github/workflows/cli_tests.yml'
- name: Read Version file
id: getversion
run: echo "::set-output name=version::$(cat VERSION)"
python-tests:
name: Python SDK Tests
needs: [changes]
if: needs.changes.outputs.python-sdk == 'true'
uses: ./.github/workflows/python_sdk_tests.yml
secrets: inherit
js-tests:
name: JS SDK Tests
needs: [changes]
if: needs.changes.outputs.js-sdk == 'true'
uses: ./.github/workflows/js_sdk_tests.yml
secrets: inherit
cli-tests:
name: CLI Tests
needs: [changes]
if: needs.changes.outputs.cli == 'true'
uses: ./.github/workflows/cli_tests.yml
secrets: inherit
release:
needs: [is_release, python-tests, js-tests, cli-tests]
if: always() && !contains(needs.*.result, 'failure') && needs.is_release.outputs.release == 'true'
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- uses: pnpm/action-setup@v3
with:
version: 9.5
- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: pnpm
- name: Configure pnpm
run: |
pnpm config set auto-install-peers true
pnpm config set exclude-links-from-lockfile true
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create new versions
run: pnpm run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release new versions
uses: changesets/action@v1
with:
publish: pnpm run publish
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Generate API Ref
run: pnpm run generate-api-reference
- name: Update lock file
run: pnpm i --no-link --no-frozen-lockfile
- name: Commit new versions
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add apps/web/src/app/\(docs\)/docs/api-reference
git commit -am "[skip ci] Release new versions" || exit 0
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
report-failure:
needs: [python-tests, js-tests, cli-tests, release]
if: failure()
name: Release Failed - Slack Notification
runs-on: ubuntu-latest
steps:
- name: Release Failed - Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: "#ff0000"
SLACK_MESSAGE: ":here-we-go-again: :bob-the-destroyer: We need :fix-parrot: ASAP :pray:"
SLACK_TITLE: Release Failed
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}