forked from asgardeo/thunder
-
Notifications
You must be signed in to change notification settings - Fork 0
693 lines (579 loc) · 26.9 KB
/
release.yml
File metadata and controls
693 lines (579 loc) · 26.9 KB
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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# This workflow will build the project and create a release on demand
# Uses:
# OS: ubuntu-latest
# Go: go 1.x
name: 🚀 Release Builder
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.0.0)'
required: true
type: string
prerelease:
description: 'Set as a pre-release'
required: false
type: boolean
default: false
run_performance_test:
description: 'Run performance tests after release'
required: false
type: boolean
default: false
# Add permissions to allow pushing tags and packages
permissions:
contents: write
packages: write
env:
GOFLAGS: "-mod=readonly"
jobs:
build-thunder:
name: ⚡ Build Thunder
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for tagging
- name: ✅ Validate Release Version
run: |
if ! [[ ${{ github.event.inputs.version }} =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-[0-9a-zA-Z.-]+)?(\+[0-9a-zA-Z.-]+)?$ ]]; then
echo "❌ Error: Version '${{ github.event.inputs.version }}' does not follow format vX.Y[.Z][-PRERELEASE][+BUILD]"
echo "❌ Version must start with 'v'"
exit 1
fi
echo "✅ Version '${{ github.event.inputs.version }}' is valid"
- name: 🏷️ Update Product Version
run: |
# Store version with v prefix in version.txt
VERSION="${{ github.event.inputs.version }}"
echo "$VERSION" > version.txt
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: 🗄️ Cache Go Modules
uses: actions/cache@v4
id: cache-go-modules
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-modules-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-modules-
- name: 📦 Install Dependencies
run: |
cd backend
go mod download
cd ../tests/integration
go mod download
- name: 🛠️ Build and Run Tests
run: |
set -e
make all OS=$(go env GOOS) ARCH=$(go env GOARCH)
- name: 🧹 Clean Previous Builds
run: make clean_all
- name: 🔐 Generate Shared Certificates
run: |
echo "🔐 Generating shared SSL certificates for all components..."
# Ensure the certificate directory exists
mkdir -p target/out/.cert
# Generate certificates
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout target/out/.cert/server.key \
-out target/out/.cert/server.cert \
-subj "/O=WSO2/OU=Thunder/CN=localhost"
echo "✅ Shared certificates generated:"
ls -la target/out/.cert/
echo "📄 Certificate info:"
openssl x509 -in target/out/.cert/server.cert -text -noout | head -10
- name: 📦 Upload Shared Certificates
uses: actions/upload-artifact@v4
with:
name: thunder-certificates
path: |
target/out/.cert/server.cert
target/out/.cert/server.key
if-no-files-found: error
- name: 🔨 Build Thunder Release Artifacts
run: |
# Define platform matrix as arrays
PLATFORMS=(
"windows:amd64"
"linux:amd64"
"linux:arm64"
"darwin:amd64"
"darwin:arm64"
)
echo "🏗️ Building Thunder for ${#PLATFORMS[@]} platforms..."
# Loop through the platform matrix
for platform in "${PLATFORMS[@]}"; do
# Split the platform string into OS and ARCH
OS="${platform%%:*}"
ARCH="${platform#*:}"
echo "🔨 Building Thunder backend for $OS/$ARCH..."
make build_backend OS=$OS ARCH=$ARCH
# Optional: Add a small delay to prevent resource contention
sleep 1
done
echo "✅ Thunder built for all platforms successfully!"
- name: 📝 Read Updated Version
id: version
run: echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
- name: 📦 Upload Backend Distribution Artifacts
uses: actions/upload-artifact@v4
with:
name: thunder-distribution
path: target/dist/*.zip
if-no-files-found: error
- name: 🏷️ Create Git Tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
TAG_VERSION="${{ github.event.inputs.version }}"
if [[ ! $TAG_VERSION == v* ]]; then
TAG_VERSION="v$TAG_VERSION"
fi
git tag -a "$TAG_VERSION" -m "Release $TAG_VERSION"
git push origin "$TAG_VERSION"
- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 🔐 Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 📥 Download Shared Certificates for Docker
uses: actions/download-artifact@v4
with:
name: thunder-certificates
path: target/out/.cert/
- name: 📋 Prepare Docker Build Context
run: |
# Copy certificates into the Docker build context
mkdir -p docker-certs
cp target/out/.cert/server.cert docker-certs/
cp target/out/.cert/server.key docker-certs/
echo "✅ Certificates prepared for Docker build context"
- name: 🐳 Build and Push Multi-Arch Docker Image
run: |
# Convert repository name to lowercase for GHCR
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
IMAGE_NAME="ghcr.io/${REPO_NAME}"
# Get version without 'v' prefix for Docker tags
DOCKER_VERSION="${{ github.event.inputs.version }}"
if [[ $DOCKER_VERSION == v* ]]; then
DOCKER_VERSION="${DOCKER_VERSION#v}"
fi
echo "🐳 Building and pushing Docker image: ${IMAGE_NAME}:${DOCKER_VERSION}"
# Build and push multi-arch image with version and latest tags
# Pass shared certificates as build context with paths relative to build context
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag "${IMAGE_NAME}:${DOCKER_VERSION}" \
--tag "${IMAGE_NAME}:latest" \
--build-arg CERT_FILE=docker-certs/server.cert \
--build-arg KEY_FILE=docker-certs/server.key \
--push \
.
echo "✅ Docker image pushed successfully!"
echo "📦 Image available at: ${IMAGE_NAME}:${DOCKER_VERSION}"
echo "📦 Image available at: ${IMAGE_NAME}:latest"
- name: 📝 Calculate Next Version
id: next_version
run: |
# Get the current release version and remove 'v' prefix
RELEASE_VERSION="${{ github.event.inputs.version }}"
if [[ $RELEASE_VERSION == v* ]]; then
RELEASE_VERSION="${RELEASE_VERSION#v}"
fi
# Parse version components (handle both X.Y and X.Y.Z formats)
if [[ $RELEASE_VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
# X.Y.Z format
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"
elif [[ $RELEASE_VERSION =~ ^([0-9]+)\.([0-9]+) ]]; then
# X.Y format
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="0"
else
echo "❌ Error: Unable to parse version format: $RELEASE_VERSION"
exit 1
fi
# Bump minor version
NEXT_MINOR=$((MINOR + 1))
NEXT_VERSION="${MAJOR}.${NEXT_MINOR}.0"
echo "✅ Next development version: $NEXT_VERSION"
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
- name: 🏷️ Update Product Version
run: |
NEXT_VERSION="v${{ steps.next_version.outputs.next_version }}"
echo "$NEXT_VERSION" > version.txt
echo "✅ Updated version.txt to $NEXT_VERSION"
- name: ⚙️ Set up Node.js for Version Update
uses: ./.github/actions/setup-node
with:
node-version: '20'
package-manager: 'npm'
dependency-path: 'samples/apps/oauth'
- name: 🏷️ Update Sample Apps Version
run: |
NEXT_VERSION="${{ steps.next_version.outputs.next_version }}"
echo "📝 Setting sample apps version to $NEXT_VERSION"
# Update the main sample app package.json
cd samples/apps/oauth
npm version $NEXT_VERSION --no-git-tag-version --allow-same-version
# Update the server package.json
cd server
npm version $NEXT_VERSION --no-git-tag-version --allow-same-version
cd ../../../..
echo "✅ Updated sample apps version to $NEXT_VERSION"
# - name: 📈 Commit and Push Version Update
# run: |
# git config --local user.email "action@github.com"
# git config --local user.name "GitHub Action"
# NEXT_VERSION="${{ steps.next_version.outputs.next_version }}"
# # Add and commit the version changes
# git add version.txt samples/apps/oauth/package.json samples/apps/oauth/server/package.json
# if ! git diff --cached --quiet; then
# git commit -m "[Release] Update version to ${NEXT_VERSION} for the next development iteration"
# git push origin HEAD:main
# echo "✅ Pushed version update to main branch"
# else
# echo "✅ No changes to commit"
# fi
package-samples-linux:
name: 📦 Package Linux & Windows Samples
runs-on: ubuntu-latest
needs: build-thunder
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: ⚙️ Set up Node.js Environment
uses: ./.github/actions/setup-node
with:
node-version: '20'
package-manager: 'npm'
dependency-path: 'samples/apps/oauth'
- name: 📥 Download Shared Certificates
uses: actions/download-artifact@v4
with:
name: thunder-certificates
path: target/out/.cert/
- name: 🏷️ Set Sample Apps Version
run: |
# Get the product version from the previous job
SAMPLE_VERSION="${{ github.event.inputs.version }}"
# Remove 'v' prefix if present
if [[ $SAMPLE_VERSION == v* ]]; then
SAMPLE_VERSION="${SAMPLE_VERSION#v}"
fi
echo "✅ Sample version set to '$SAMPLE_VERSION'"
echo "SAMPLE_VERSION=$SAMPLE_VERSION" >> $GITHUB_ENV
- name: 📝 Update Sample Apps Version
run: |
# Get the clean sample version without v prefix
SAMPLE_VERSION="${{ env.SAMPLE_VERSION }}"
echo "📝 Setting sample apps version to $SAMPLE_VERSION"
# Update the main sample app package.json
cd samples/apps/oauth
npm version $SAMPLE_VERSION --no-git-tag-version --allow-same-version
# Update the server package.json
cd server
npm version $SAMPLE_VERSION --no-git-tag-version --allow-same-version
cd ../../../..
echo "✅ Updated sample apps version to $SAMPLE_VERSION"
- name: 🔨 Build Sample Apps (Once)
run: |
echo "🔨 Building sample apps (shared for all platforms)..."
make build_samples
- name: 📦 Package Linux Samples
run: |
echo "📦 Packaging Linux samples..."
make package_samples OS=linux ARCH=x64
make package_samples OS=linux ARCH=arm64
- name: 📦 Package Windows Samples
run: |
echo "📦 Packaging Windows samples..."
make package_samples OS=win ARCH=x64
- name: 📦 Upload Linux & Windows Sample Artifacts
uses: actions/upload-artifact@v4
with:
name: thunder-samples-linux-windows
path: target/dist/*.zip
if-no-files-found: error
package-samples-macos:
name: 📦 Package macOS Samples
runs-on: macos-latest
needs: build-thunder
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: ⚙️ Set up Go Environment
uses: ./.github/actions/setup-go
- name: ⚙️ Set up Node.js Environment
uses: ./.github/actions/setup-node
with:
node-version: '20'
package-manager: 'npm'
dependency-path: 'samples/apps/oauth'
- name: 📥 Download Shared Certificates
uses: actions/download-artifact@v4
with:
name: thunder-certificates
path: target/out/.cert/
- name: 🏷️ Set Sample Apps Version
run: |
# Get the product version from the previous job
SAMPLE_VERSION="${{ github.event.inputs.version }}"
# Remove 'v' prefix if present
if [[ $SAMPLE_VERSION == v* ]]; then
SAMPLE_VERSION="${SAMPLE_VERSION#v}"
fi
echo "✅ Sample version set to '$SAMPLE_VERSION'"
echo "SAMPLE_VERSION=$SAMPLE_VERSION" >> $GITHUB_ENV
- name: 📝 Update Sample Apps Version
run: |
# Get the clean sample version without v prefix
SAMPLE_VERSION="${{ env.SAMPLE_VERSION }}"
echo "📝 Setting sample apps version to $SAMPLE_VERSION"
# Update the main sample app package.json
cd samples/apps/oauth
npm version $SAMPLE_VERSION --no-git-tag-version --allow-same-version
# Update the server package.json
cd server
npm version $SAMPLE_VERSION --no-git-tag-version --allow-same-version
cd ../../../..
echo "✅ Updated sample apps version to $SAMPLE_VERSION"
- name: 🔨 Build and Package macOS Samples
run: |
make build_samples
# Package for both x64 and arm64
make package_samples OS=macos ARCH=x64
make package_samples OS=macos ARCH=arm64
- name: 📦 Upload macOS Sample Artifacts
uses: actions/upload-artifact@v4
with:
name: thunder-samples-macos
path: target/dist/*.zip
if-no-files-found: error
release:
name: 🚀 Release
runs-on: ubuntu-latest
needs: [build-thunder, package-samples-linux, package-samples-macos]
outputs:
release_tag: ${{ steps.release_info.outputs.release_tag }}
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📥 Download Backend Artifacts
uses: actions/download-artifact@v4
with:
name: thunder-distribution
path: ./backend-artifacts
- name: 📥 Download Linux & Windows Sample Artifacts
uses: actions/download-artifact@v4
with:
name: thunder-samples-linux-windows
path: ./linux-windows-artifacts
- name: 📥 Download macOS Sample Artifacts
uses: actions/download-artifact@v4
with:
name: thunder-samples-macos
path: ./macos-artifacts
- name: 📦 Combine All Distribution Artifacts
run: |
mkdir -p target/dist
# Copy backend artifacts
cp ./backend-artifacts/*.zip target/dist/ || true
# Copy sample artifacts from each platform
cp ./linux-windows-artifacts/*.zip target/dist/ || true
cp ./macos-artifacts/*.zip target/dist/ || true
echo "✅ Combined all artifacts:"
ls -la target/dist/
- name: 📦 Upload Final Combined Artifacts
uses: actions/upload-artifact@v4
with:
name: thunder-final-distribution
path: target/dist/*.zip
if-no-files-found: error
- name: 📝 Read Version
id: version
run: |
VERSION="${{ github.event.inputs.version }}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: 📝 Generate Changelog (Release Drafter)
id: changelog
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
name: Thunder ${{ github.event.inputs.version }}
tag: ${{ github.event.inputs.version }}
prerelease: ${{ github.event.inputs.prerelease }}
publish: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: ⏳ Wait for Release Drafter to Complete
run: |
echo "⏳ Waiting for release-drafter to fully create the draft release..."
sleep 10
echo "✅ Proceeding with release creation"
- name: 📝 Extract README Content for Release
id: readme_extract
run: |
# Get the release version without v prefix for replacement
RELEASE_VERSION="${{ github.event.inputs.version }}"
if [[ $RELEASE_VERSION == v* ]]; then
RELEASE_VERSION="${RELEASE_VERSION#v}"
fi
# Extract introduction (everything before first --- divider)
INTRO=$(awk 'BEGIN{flag=1} /^---$/{flag=0; exit} flag{print}' README.md)
# Extract Quick Start section
QUICKSTART=$(sed -n '/^## ⚡ Quickstart/,/^---$/p' README.md | head -n -1)
# Extract license section including header
LICENSE=$(grep -A 5 "^## License" README.md)
# Replace <version> placeholders with actual version
INTRO=$(echo "$INTRO" | sed "s/<version>/$RELEASE_VERSION/g")
QUICKSTART=$(echo "$QUICKSTART" | sed "s/<version>/$RELEASE_VERSION/g")
# Replace 'latest' placeholders with actual version for release notes
INTRO=$(echo "$INTRO" | sed "s/:latest/:$RELEASE_VERSION/g")
QUICKSTART=$(echo "$QUICKSTART" | sed "s/:latest/:$RELEASE_VERSION/g")
INTRO=$(echo "$INTRO" | sed "s/latest release/$RELEASE_VERSION release/g")
QUICKSTART=$(echo "$QUICKSTART" | sed "s/latest release/$RELEASE_VERSION release/g")
# Handle other 'latest' references
INTRO=$(echo "$INTRO" | sed "s/latest release of WSO2 Thunder/$RELEASE_VERSION release of WSO2 Thunder/g")
QUICKSTART=$(echo "$QUICKSTART" | sed "s/latest release of WSO2 Thunder/$RELEASE_VERSION release of WSO2 Thunder/g")
# Add direct download links for Thunder server - replace download instruction and example paragraph
# Create the Thunder downloads table with proper newlines using printf
THUNDER_TABLE=$(printf "%s\n%s\n%s\n%s\n%s\n%s\n%s" \
"| OS | Architecture | Download Link |" \
"|-------|-------------|-------------|" \
"| macOS | ARM64 (Apple Silicon) | [thunder-${RELEASE_VERSION}-macos-arm64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/thunder-${RELEASE_VERSION}-macos-arm64.zip) |" \
"| macOS | x64 (Intel) | [thunder-${RELEASE_VERSION}-macos-x64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/thunder-${RELEASE_VERSION}-macos-x64.zip) |" \
"| Linux | x64 | [thunder-${RELEASE_VERSION}-linux-x64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/thunder-${RELEASE_VERSION}-linux-x64.zip) |" \
"| Linux | ARM64 | [thunder-${RELEASE_VERSION}-linux-arm64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/thunder-${RELEASE_VERSION}-linux-arm64.zip) |" \
"| Windows | x64 | [thunder-${RELEASE_VERSION}-win-x64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/thunder-${RELEASE_VERSION}-win-x64.zip) |")
# Replace the download instruction with the table using awk for proper handling
QUICKSTART=$(echo "$QUICKSTART" | awk -v table="$THUNDER_TABLE" '
/Download `thunder-.*-<os>-<arch>\.zip` from the \[.*release\]/ {
print table
next
}
{ print }
')
# Remove the example paragraph that follows (it's now redundant with the table)
QUICKSTART=$(echo "$QUICKSTART" | sed '/For example, if you are using a MacOS machine with a Apple Silicon (ARM64) processor, you would download `thunder-'"$RELEASE_VERSION"'-macos-arm64\.zip`\./d')
# Create the Sample App downloads table with proper newlines using printf
SAMPLE_TABLE=$(printf "%s\n%s\n%s\n%s\n%s\n%s\n%s" \
"| OS | Architecture | Download Link |" \
"|-------|-------------|-------------|" \
"| macOS | ARM64 (Apple Silicon) | [sample-app-${RELEASE_VERSION}-macos-arm64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/sample-app-${RELEASE_VERSION}-macos-arm64.zip) |" \
"| macOS | x64 (Intel) | [sample-app-${RELEASE_VERSION}-macos-x64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/sample-app-${RELEASE_VERSION}-macos-x64.zip) |" \
"| Linux | x64 | [sample-app-${RELEASE_VERSION}-linux-x64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/sample-app-${RELEASE_VERSION}-linux-x64.zip) |" \
"| Linux | ARM64 | [sample-app-${RELEASE_VERSION}-linux-arm64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/sample-app-${RELEASE_VERSION}-linux-arm64.zip) |" \
"| Windows | x64 | [sample-app-${RELEASE_VERSION}-win-x64.zip](https://github.com/${{ github.repository }}/releases/download/v${RELEASE_VERSION}/sample-app-${RELEASE_VERSION}-win-x64.zip) |")
# Replace the sample app download instruction with the table using awk
QUICKSTART=$(echo "$QUICKSTART" | awk -v table="$SAMPLE_TABLE" '
/Download `sample-app-.*-<os>-<arch>\.zip` from the \[.*release\]/ {
print table
next
}
{ print }
')
# Get changelog from Release Drafter
CHANGELOG="${{ steps.changelog.outputs.body }}"
# Combine for release description
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
echo "$INTRO" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "## 🔀 What's Changed" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "$QUICKSTART" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "$LICENSE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: 📦 Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: Thunder ${{ steps.version.outputs.version }}
draft: false
prerelease: ${{ github.event.inputs.prerelease }}
files: target/dist/*.zip
body: ${{ env.RELEASE_BODY }}
generate_release_notes: false
- name: 🔔 Set Release Info
id: release_info
run: |
RELEASE_VERSION="${{ steps.version.outputs.version }}"
echo "release_name=Thunder ${RELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "release_tag=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "release_url=https://github.com/${{ github.repository }}/releases/tag/${RELEASE_VERSION}" >> $GITHUB_OUTPUT
- name: 🔔 Send Release Notification
uses: ./.github/actions/release-notification
with:
webhook: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
release-name: ${{ steps.release_info.outputs.release_name }}
release-tag: ${{ steps.release_info.outputs.release_tag }}
release-url: ${{ steps.release_info.outputs.release_url }}
trigger-performance-test:
name: 🧪 Trigger Performance Test
runs-on: ubuntu-latest
needs: release
if: ${{ github.event.inputs.run_performance_test == 'true' }}
steps:
- name: 📥 Checkout Code
uses: actions/checkout@v4
- name: ⚡ Trigger Performance Test Workflows
uses: actions/github-script@v7
with:
github-token: ${{ secrets.THUNDER_GITHUB_BOT_TOKEN }}
script: |
// Construct the Thunder pack URL using the release version
const releaseTag = '${{ needs.release.outputs.release_tag }}';
const thunderPackUrl = `https://github.com/${{ github.repository }}/releases/download/${releaseTag}/thunder-${releaseTag.replace('v', '')}-linux-x64.zip`;
const pushBenchmarkToGitHub = ${{ github.repository == 'asgardeo/thunder' }};
// Define CPU core configurations to test
const cpuCoreConfigs = ['4', '8'];
// Loop through each CPU core configuration and trigger a separate workflow
for (const cpuCores of cpuCoreConfigs) {
console.log(`🔄 Triggering performance test with ${cpuCores} CPU cores`);
try {
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'asgardeo',
repo: 'thunder-performance',
workflow_id: 'vm-perf-workflow.yml',
ref: 'main',
inputs: {
THUNDER_PACK_URL: thunderPackUrl,
DEPLOYMENT: 'single-node',
CPU_CORES: cpuCores,
ADDITIONAL_PARAMS_TO_RUN_PERFORMANCE_SCRIPT: '-d 15 -w 5 -x false -y JWT',
PERFORMANCE_REPO: 'https://github.com/asgardeo/thunder-performance',
BRANCH: 'main',
MODE: 'FULL',
USE_DELAYS: 'true',
CONCURRENCY: '50-3000',
PUSH_BENCHMARKS_TO_GITHUB: pushBenchmarkToGitHub
}
});
console.log(`✅ Performance test workflow with ${cpuCores} CPU cores triggered successfully`);
} catch (error) {
console.error(`❌ Failed to trigger performance test workflow with ${cpuCores} CPU cores:`, error);
// Continue with next configuration even if one fails
}
}
// Return success
return {success: true};