-
-
Notifications
You must be signed in to change notification settings - Fork 127
425 lines (373 loc) · 14.4 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
name: Release and deploy
on:
push:
branches:
- main
- develop
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
environment: ${{ github.ref == 'refs/heads/main' && 'alpha' || 'stage' }}
latestTag: ${{ github.ref == 'refs/heads/main' && 'latest' || 'experimental' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
- name: Install PNPM
run: npm i -g pnpm
- name: Install
run: pnpm i
- name: Release
id: release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
GITHUB_CLIENT_ID: dummy
GITHUB_CLIENT_SECRET: dummy
GITHUB_CALLBACK_URL: dummy
REDIS_URL: redis://localhost:6379
JWT_SECRET: secret
run: pnpm dlx semantic-release
deploy-api:
needs: release
runs-on: ubuntu-latest
environment: ${{ needs.release.outputs.environment }}
name: Deploy API
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Login
uses: azure/docker-login@v2
with:
login-server: ${{ vars.ACR_REGISTRY_URL }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build and push docker image
id: build
env:
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: api
LATEST_TAG: ${{ needs.release.outputs.latestTag }}
run: |
VERSION=`jq -r '.version' package.json`
# Build a docker container and push it to ACR
docker build \
-t $ACR_REGISTRY_URL/$REPOSITORY_NAME:$VERSION \
-t $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG \
-f ./apps/api/Dockerfile .
echo "Pushing image to ACR..."
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:$VERSION
echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Azure Login action
uses: azure/login@v2
with:
creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }}
enable-AzPSSession: true
- name: Update Azure Container App
uses: azure/cli@v2
env:
API_CONTAINER: ${{ vars.API_CONTAINER }}
API_CONTAINER_RG: ${{ vars.API_CONTAINER_RG }}
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: api
with:
azcliversion: latest
inlineScript: |
az containerapp update \
--name $API_CONTAINER \
--resource-group $API_CONTAINER_RG \
--image $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG
migrate-api:
name: Apply Database Migrations
runs-on: ubuntu-latest
environment: ${{ needs.release.outputs.environment }}
needs: [deploy-api, release]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PNPM
run: npm i -g pnpm
- name: Install
run: pnpm i
- name: Run migrations
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: |
# Run migrations
pnpm db:generate-types
pnpm db:deploy-migrations
release-sentry-api:
name: Sentry API
runs-on: ubuntu-latest
environment: ${{ needs.release.outputs.environment }}
needs: [deploy-api, release]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PNPM
run: npm i -g pnpm
- name: Install
run: pnpm i
- name: Sentry Release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_API_PROJECT }}
ENVIRONMENT: ${{ needs.release.outputs.environment }}
run: |
RELEASE=`jq -r '.version' package.json`
sentry-cli releases new $RELEASE
sentry-cli releases set-commits --auto $RELEASE
sentry-cli releases deploys $RELEASE new -e $ENVIRONMENT
sentry-cli releases files $RELEASE upload-sourcemaps apps/api/.dist \
--validate \
--rewrite
deploy-platform:
needs: release
runs-on: ubuntu-latest
environment: ${{ needs.release.outputs.environment }}
name: Deploy Platform
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Login
uses: azure/docker-login@v2
with:
login-server: ${{ vars.ACR_REGISTRY_URL }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build and push docker image
id: build
env:
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: platform
LATEST_TAG: ${{ needs.release.outputs.latestTag }}
NEXT_PUBLIC_BACKEND_URL: ${{ vars.NEXT_PUBLIC_BACKEND_URL }}
NEXT_PUBLIC_SENTRY_PLATFORM_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_PLATFORM_DSN }}
NEXT_PUBLIC_SENTRY_PLATFORM_PROFILE_SAMPLE_RATE: ${{ vars.NEXT_PUBLIC_SENTRY_PLATFORM_PROFILE_SAMPLE_RATE }}
NEXT_PUBLIC_SENTRY_PLATFORM_TRACES_SAMPLE_RATE: ${{ vars.NEXT_PUBLIC_SENTRY_PLATFORM_TRACES_SAMPLE_RATE }}
NEXT_PUBLIC_SENTRY_ENVIRONMENT: ${{ needs.release.outputs.environment }}
run: |
VERSION=`jq -r '.version' package.json`
# Build a docker container and push it to ACR
docker build \
-t $ACR_REGISTRY_URL/$REPOSITORY_NAME:$VERSION \
-t $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG \
--build-arg NEXT_PUBLIC_BACKEND_URL=$NEXT_PUBLIC_BACKEND_URL \
-f ./apps/platform/Dockerfile .
echo "Pushing image to ACR..."
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:$VERSION
echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Azure Login action
uses: azure/login@v2
with:
creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }}
enable-AzPSSession: true
- name: Update Azure Container App
uses: azure/cli@v2
env:
PLATFORM_CONTAINER: ${{ vars.PLATFORM_CONTAINER }}
PLATFORM_CONTAINER_RG: ${{ vars.PLATFORM_CONTAINER_RG }}
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: platform
with:
azcliversion: latest
inlineScript: |
az containerapp update \
--name $PLATFORM_CONTAINER \
--resource-group $PLATFORM_CONTAINER_RG \
--image $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG
release-sentry-platform:
name: Sentry Platform
runs-on: ubuntu-latest
environment: ${{ needs.release.outputs.environment }}
needs: [deploy-api, deploy-web, deploy-platform, release]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Sentry CLI
run: npm i -g @sentry/cli
- name: Sentry Release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_PLATFORM_PROJECT }}
ENVIRONMENT: ${{ needs.release.outputs.environment }}
run: |
RELEASE=`jq -r '.version' package.json`
sentry-cli releases -o $SENTRY_ORG new -p $SENTRY_PROJECT $VERSION
sentry-cli releases set-commits --auto $VERSION
sentry-cli releases deploys $VERSION new -e $ENVIRONMENT
sentry-cli releases files $VERSION upload-sourcemaps apps/platform/.next \
--url-prefix '~/_next' \
--validate \
--rewrite
deploy-web:
runs-on: ubuntu-latest
environment: ${{ needs.release.outputs.environment }}
name: Deploy Web
needs: release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Login
uses: azure/docker-login@v2
with:
login-server: ${{ vars.ACR_REGISTRY_URL }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build Docker image
id: build
env:
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: web
LATEST_TAG: ${{ needs.release.outputs.latestTag }}
NEXT_PUBLIC_GOOGLE_ANALYTICS_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_MEASUREMENT_ID }}
NEXT_PUBLIC_SENTRY_WEB_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_WEB_DSN }}
NEXT_PUBLIC_SENTRY_WEB_PROFILE_SAMPLE_RATE: ${{ vars.NEXT_PUBLIC_SENTRY_WEB_PROFILE_SAMPLE_RATE }}
NEXT_PUBLIC_SENTRY_WEB_TRACES_SAMPLE_RATE: ${{ vars.NEXT_PUBLIC_SENTRY_WEB_TRACES_SAMPLE_RATE }}
NEXT_PUBLIC_SENTRY_ENVIRONMENT: ${{ needs.release.outputs.environment }}
run: |
VERSION=`jq -r '.version' package.json`
# Build a docker container and push it to ACR
docker build \
-t $ACR_REGISTRY_URL/$REPOSITORY_NAME:$VERSION \
-t $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG \
--build-arg NEXT_PUBLIC_GOOGLE_ANALYTICS_MEASUREMENT_ID=$NEXT_PUBLIC_GOOGLE_ANALYTICS_MEASUREMENT_ID \
--build-arg NEXT_PUBLIC_SENTRY_WEB_DSN=$NEXT_PUBLIC_SENTRY_WEB_DSN \
--build-arg NEXT_PUBLIC_SENTRY_WEB_PROFILE_SAMPLE_RATE=$NEXT_PUBLIC_SENTRY_WEB_PROFILE_SAMPLE_RATE \
--build-arg NEXT_PUBLIC_SENTRY_WEB_TRACES_SAMPLE_RATE=$NEXT_PUBLIC_SENTRY_WEB_TRACES_SAMPLE_RATE \
--build-arg NEXT_PUBLIC_SENTRY_ENVIRONMENT=$NEXT_PUBLIC_SENTRY_ENVIRONMENT \
-f ./apps/web/Dockerfile .
echo "Pushing image to ACR..."
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG
docker push $ACR_REGISTRY_URL/$REPOSITORY_NAME:$VERSION
echo "name=image::$ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG" >> $GITHUB_OUTPUT
- name: Azure Login action
uses: azure/login@v2
with:
creds: ${{ secrets.CONTAINER_APP_SP_CREDENTIALS }}
enable-AzPSSession: true
- name: Azure CLI script
uses: azure/cli@v2
env:
WEB_CONTAINER: ${{ vars.WEB_CONTAINER }}
WEB_CONTAINER_RG: ${{ vars.WEB_CONTAINER_RG }}
ACR_REGISTRY_URL: ${{ vars.ACR_REGISTRY_URL }}
REPOSITORY_NAME: web
with:
azcliversion: latest
inlineScript: |
az containerapp update \
--name $WEB_CONTAINER \
--resource-group $WEB_CONTAINER_RG \
--image $ACR_REGISTRY_URL/$REPOSITORY_NAME:$LATEST_TAG
sentry-release-web:
name: Sentry Web
needs: [release, deploy-web]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Sentry CLI
run: npm i -g @sentry/cli
- name: Sentry Release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_WEB_PROJECT }}
ENVIRONMENT: ${{ needs.release.outputs.environment }}
run: |
RELEASE=`jq -r '.version' package.json`
sentry-cli releases new $RELEASE
sentry-cli releases set-commits --auto $RELEASE
sentry-cli releases deploys $RELEASE new -e $ENVIRONMENT
sentry-cli releases files $RELEASE upload-sourcemaps apps/web/.next \
--url-prefix '~/_next' \
--validate \
--rewrite
publish-cli:
needs: release
name: Publish CLI
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Check branch
run: |
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
echo "Skipping publish for non-main branch."
exit 0
fi
- name: Check versions
id: check-versions
run: |
current_version=$(jq -r '.version' apps/cli/package.json)
published_version=$(npm show @keyshade/cli version)
if [ "$current_version" == "$published_version" ]; then
echo "Published version of @keyshade/cli is same as the current version: $current_version. Skipping publish."
exit 0
fi
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
scope: '@keyshade'
- name: Get published version
id: published_version
run: echo "published_version=$(npm show @keyshade/cli version)" >> $GITHUB_ENV
- name: Install pnpm
run: npm i -g pnpm
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build:cli
- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Publish
run: cd apps/cli && npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
sentry-release-cli:
name: Sentry CLI
needs: [release, publish-cli]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: node
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: https://registry.npmjs.org
- name: Install sentry-cli
run: npm i -g @sentry/cli
- name: Make release
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_CLI_PROJECT }}
VERSION: ${{ needs.release.outputs.version }}
ENVIRONMENT: ${{ needs.release.outputs.environment }}
run: |
# CLI
VERSION=`jq -r '.version' apps/cli/package.json`
sentry-cli releases new -p $SENTRY_PROJECT $VERSION
sentry-cli releases set-commits --auto $VERSION
sentry-cli releases deploys $VERSION new -e $ENVIRONMENT
sentry-cli releases files $VERSION upload-sourcemaps apps/cli/.dist \
--validate \
--rewrite