forked from Redocly/redocly-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (183 loc) · 6.63 KB
/
release.yaml
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
201
202
203
204
205
206
207
name: Release
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: RomanHotsiy/changesets-action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: npm run release
commit: 'chore: 🔖 release new versions'
title: 'chore: 🔖 release new versions'
version: |
npx changeset version
npm i
node scripts/post-changeset.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
deploy:
needs: [release]
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- run: npm ci
- name: Bundle into single file
run: npm run webpack-bundle
- name: Upload to AWS S3 bucket
run: npm run upload
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
AWS_S3_PATH: openapi-cli-dist
- name: Upload to AWS sandbox S3 bucket
run: npm run upload
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_SANDBOX_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SANDBOX_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
AWS_S3_PATH: redocly-sandbox-openapi-cli-dist
dockerhub:
needs: [release]
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get version
id: get_version
run: |
value="$(cat packages/cli/package.json | jq -r '.version')"
echo "value=$value" >> "$GITHUB_OUTPUT"
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: |
redocly/cli
ghcr.io/redocly/cli
tags: |
${{ steps.get_version.outputs.value }}
latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
post-release-smoke-checks:
needs:
- release
- deploy
- dockerhub
name: Test released version
continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Install CLI from npm
run: npm i -g @redocly/cli@latest
- name: Test version from NPM
continue-on-error: true
run: |
expected_version="$(cat packages/cli/package.json | jq -r '.version')"
actual_version="$(redocly --version)"
if [[ $expected_version == $actual_version ]]; then
echo "The version is correct. Actual version: $actual_version"
else
echo "The version is incorrect. Expected: $expected_version, actual: $actual_version"
fi
redocly lint https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml --format=stylish
redocly bundle https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml -o bundled.json
redocly build-docs https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
- name: Pull docker image
run: docker pull redocly/cli:latest
- name: Test docker image
continue-on-error: true
run: |
expected_version="$(cat packages/cli/package.json | jq -r '.version')"
actual_version="$(docker run --rm redocly/cli --version)"
if [[ $expected_version == $actual_version ]]; then
echo "The version is correct. Actual version: $actual_version"
else
echo "The version is incorrect. Expected: $expected_version, actual: $actual_version"
fi
docker run --rm redocly/cli lint https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
docker run --rm redocly/cli bundle https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml --output=bundled.yaml
docker run --rm redocly/cli build-docs https://raw.githubusercontent.com/Rebilly/api-definitions/main/openapi/openapi.yaml
notify:
needs:
- release
- post-release-smoke-checks
if: needs.release.outputs.published == 'true'
name: Send the Release Message to Slack
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Install Dependencies
run: npm ci
- name: Write release message to file
run: node scripts/write-release-message.js
- name: Send to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: C019K52TC0L #releases
payload-file-path: './output/release-message.json'
env:
SLACK_BOT_TOKEN: ${{ secrets.RELEASES_SLACK_BOT_TOKEN }}