-
Notifications
You must be signed in to change notification settings - Fork 0
778 lines (702 loc) · 31.5 KB
/
Copy pathrelease.yml
File metadata and controls
778 lines (702 loc) · 31.5 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
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
name: Products Release Notes and Tag
defaults:
run:
shell: bash
env:
TOKEN: ${{ secrets.X_TOKEN }}
RELEASE_URL: ${{ vars.RELEASE_URL }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_CONFIG: ${{ secrets.SSH_CONFIG }}
LOCAL_HOST: ${{ secrets.LOCAL_HOST }}
LOCAL_PORT: ${{ secrets.LOCAL_PORT }}
OSS_EP: ${{ secrets.OSS_EP }}
OSS_AK: ${{ secrets.OSS_AK }}
OSS_SK: ${{ secrets.OSS_SK }}
OSS_BK: ${{ secrets.OSS_BK }}
OSS_MODE: ${{ secrets.OSS_MODE }}
CONNECT_SERVER: ${{ secrets.CONNECT_SERVER }}
CONNECT_PORT: ${{ secrets.CONNECT_PORT }}
CONNECT_KEY: ${{ secrets.CONNECT_KEY }}
CONNECT_TIMEOUT: ${{ vars.CONNECT_TIMEOUT }}
CONNECT_MODE: ${{ vars.CONNECT_MODE }}
CONNECT_METHOD: ${{ secrets.CONNECT_METHOD }}
PUBLISH_VERSION: ${{ inputs.PUBLISH_VERSION || vars.PUBLISH_VERSION }}
on:
workflow_dispatch:
inputs:
OPERATION:
description: 'Create PR/TAG'
required: true
type: choice
options: ['PR', 'TAG', 'RELEASE']
default: "1.30.2-2396"
PUBLISH_FRAMEWORK_VERSION:
description: 'Publish Framework Version'
required: false
default: "1.4.0"
PUBLISH_VERSION:
description: 'Publish Products Release Version'
required: false
default: "1.30.3-2407"
PUBLISH_EZS_VERSION:
description: 'Publish Easysearch Version'
required: false
default: "2.1.0-2661"
PUBLISH_COCO_APP_VERSION:
description: 'Publish Coco App Version'
required: false
default: "0.10.0-2619"
PUBLISH_COCO_VERSION:
description: 'Publish Coco Server Version'
required: false
default: "0.10.0-2672"
EASYSEARCH_PUBLISH:
description: 'Easysearch'
required: false
type: boolean
default: true
PRODUCTS_PUBLISH:
description: 'Products with agent/console...'
required: false
type: boolean
default: true
COCO_PUBLISH:
description: 'Products with coco app/server...'
required: false
type: boolean
default: true
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.gen-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Generate matrix
id: gen-matrix
env:
AGENT_PUBLISH: ${{ inputs.PRODUCTS_PUBLISH }}
CONSOLE_PUBLISH: ${{ inputs.PRODUCTS_PUBLISH }}
GATEWAY_PUBLISH: ${{ inputs.PRODUCTS_PUBLISH }}
LOADGEN_PUBLISH: ${{ inputs.PRODUCTS_PUBLISH }}
FRAMEWORK_PUBLISH: ${{ inputs.PRODUCTS_PUBLISH }}
EASYSEARCH_PUBLISH: ${{ inputs.EASYSEARCH_PUBLISH }}
COCO_APP_PUBLISH: ${{ inputs.COCO_PUBLISH }}
COCO_SERVER_PUBLISH: ${{ inputs.COCO_PUBLISH }}
run: |
matrix=$($GITHUB_WORKSPACE/scripts/go-matrix.sh)
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
cat "$GITHUB_OUTPUT"
create-pr:
needs: generate-matrix
if: ${{ inputs.OPERATION == 'PR' }}
name: Create PR for ${{ matrix.product }}
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
max-parallel: 1
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup bootstrap
uses: ./containers/bootstrap
- name: Set up env for PR
run: |
if [[ "${{ matrix.product }}" == "framework" ]]; then
VERSION=${{ inputs.PUBLISH_FRAMEWORK_VERSION }}
elif [[ "${{ matrix.product }}" == "easysearch" ]]; then
EZS_VER=${{ inputs.PUBLISH_EZS_VERSION }}
VER=${{ env.PUBLISH_VERSION }}
SUFFIX=${VER#*-}
if [[ "$VER" == *"-"* ]] && [[ "$EZS_VER" != *"-"* ]] && [[ -n "$SUFFIX" ]]; then
VERSION="${EZS_VER}-$SUFFIX"
else
VERSION=$EZS_VER
fi
elif [[ "${{ matrix.product }}" == "coco-app" ]]; then
VERSION=${{ inputs.PUBLISH_COCO_APP_VERSION }}
elif [[ "${{ matrix.product }}" == "coco-server" ]]; then
VERSION=${{ inputs.PUBLISH_COCO_VERSION }}
else
VERSION=${{ env.PUBLISH_VERSION }}
fi
if [[ -z "$VERSION" ]]; then
echo "Error: Version is empty for ${{ matrix.product }}"
exit 1
fi
PR_BRANCH="ci_release_$VERSION"
PR_MESSAGE="chore: update release notes for publish $VERSION"
echo "PNAME=${{ matrix.product }}" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_ENV
echo "PR_MESSAGE=$PR_MESSAGE" >> $GITHUB_ENV
- name: Run connect in background (Easysearch only)
if: ${{ matrix.product == 'easysearch' }}
run: |
connect -c "$GITHUB_WORKSPACE/.net.json" >/dev/null 2>&1 &
echo "Connect started with pid $!"
sleep 5
- name: Checkout code for ${{ matrix.product }}
timeout-minutes: 30
run: |
if [[ "${{ matrix.product }}" == "easysearch" ]]; then
git clone ${{ secrets.SSH_GIT_REPO }}/${{ matrix.product }} $GITHUB_WORKSPACE/${{ matrix.product }}
else
git clone ${{ vars.GIT_SSH_REPO }}/${{ matrix.product }} $GITHUB_WORKSPACE/${{ matrix.product }}
fi
cd $GITHUB_WORKSPACE/${{ matrix.product }} && echo Checkout $PNAME repo $(git log -1 --pretty=format:"%h, %ad, %an, %s")
git config user.name github-actions
git config user.email github-actions@github.com
- name: Create Branch and update release notes & data
continue-on-error: true
run: |
VER=${{ inputs.PUBLISH_VERSION }}
FRAMEWORK_VER=${{ inputs.PUBLISH_FRAMEWORK_VERSION }}
EZS_VER=${{ inputs.PUBLISH_EZS_VERSION }}
cd $GITHUB_WORKSPACE/${{ matrix.product }}
# Check if the branch already exists
if git ls-remote --heads origin "$PR_BRANCH" | grep -q "$PR_BRANCH"; then
echo "Branch $PR_BRANCH found. Deleting remote branch..."
git push origin --delete "$PR_BRANCH"
fi
echo "Create Branch $PR_BRANCH for ${{ matrix.product }}"
git checkout -b "$PR_BRANCH"
PUBLISH="$(echo "$VERSION" | sed 's/-.*//') ($(date +'%Y-%m-%d'))"
PRODUCT_NAME=$(echo "${{ matrix.product }}" | sed 's/./\u&/')
for f in en zh; do
if [[ ! -d docs/content.$f ]]; then continue; fi
FRAMEWORK_UPDATE_NOTES="- This release includes updates from the underlying [Framework v${FRAMEWORK_VER}](https://docs.infinilabs.com/framework/v${FRAMEWORK_VER}), which resolves several common issues and enhances overall stability and performance. While there are no direct changes to ${PRODUCT_NAME} itself, the improvements inherited from Framework benefit ${PRODUCT_NAME} indirectly."
if [[ "$f" == "zh" ]]; then
FRAMEWORK_UPDATE_NOTES="- 此版本包含了底层 [Framework v${FRAMEWORK_VER}](https://docs.infinilabs.com/framework/v${FRAMEWORK_VER}) 的更新,解决了一些常见问题,并增强了整体稳定性和性能。虽然 ${PRODUCT_NAME} 本身没有直接的变更,但从 Framework 中继承的改进间接地使 ${PRODUCT_NAME} 受益。"
fi
if ! grep -wq "$(echo "$VERSION" | sed 's/-.*//')" docs/content.$f/docs/release-notes/_index.md; then
if [[ "${{ matrix.product }}" == "console" || "${{ matrix.product }}" == "agent" || "${{ matrix.product }}" == "gateway" || "${{ matrix.product }}" == "loadgen" ]]; then
sed -i "0,/^[[:space:]]*###\{1,2\}[[:space:]]*✈️[[:space:]]*Improvements[[:space:]]*$/s||&\n$FRAMEWORK_UPDATE_NOTES|" docs/content.$f/docs/release-notes/_index.md
fi
sed -i "s/## Latest.*/## $PUBLISH/" docs/content.$f/docs/release-notes/_index.md
sed -i -e "/^## $PUBLISH/i ## Latest (In development) \\n### ❌ Breaking changes \\n### 🚀 Features \\n### 🐛 Bug fix \\n### ✈️ Improvements \\n" docs/content.$f/docs/release-notes/_index.md
git add docs/content.$f/docs/release-notes/_index.md
fi
done
if [[ -d docs/data ]]; then
sed -i "s/version:.*/version: '$VERSION',/" docs/data/quick_start.yaml
if [[ "${{ matrix.product }}" == "easysearch" ]]; then
sed -i "19s/version:.*/version: '$PUBLISH_VERSION'/" docs/data/quick_start.yaml
fi
if [[ "${{ matrix.product }}" == "console" ]]; then
sed -i "44s/version:.*/version: '$EZS_VER',/" docs/data/quick_start.yaml
fi
git add docs/data/quick_start.yaml
fi
- name: Create Commit Message
id: commit_and_push
run: |
cd $GITHUB_WORKSPACE/${{ matrix.product }}
if [[ -n $(git status --porcelain) ]]; then
echo "✅ Changes detected. Proceeding with commit and push..."
git commit -m "$PR_MESSAGE"
git push origin "$PR_BRANCH"
echo "changes_pushed=true" >> $GITHUB_OUTPUT
else
echo "🤷 No changes detected. Skipping commit and push."
echo "changes_pushed=false" >> $GITHUB_OUTPUT
fi
if [[ "${{ matrix.product }}" == "easysearch" ]]; then
git remote set-url origin https://${{ secrets.HTTP_GIT_REPO }}/infini/${{ matrix.product }}
fi
- name: Create Github Pull Request
if: ${{ steps.commit_and_push.outputs.changes_pushed == 'true' && matrix.product != 'easysearch' }}
env:
GH_TOKEN: ${{ secrets.REPO_PAT }}
run: |
cd $GITHUB_WORKSPACE/${{ matrix.product }}
if ! gh label list --repo "${{vars.GIT_REPO}}/${{ matrix.product }}" | grep -q "auto-merge"; then
gh label create "auto-merge" --repo "${{vars.GIT_REPO}}/${{ matrix.product }}" --description "Automatically merge this PR" --color 34d058 --force
fi
if ! gh label list --repo "${{vars.GIT_REPO}}/${{ matrix.product }}" | grep -q "automated"; then
gh label create "automated" --repo "${{vars.GIT_REPO}}/${{ matrix.product }}" --description "Automated create this PR" --color 34d058 --force
fi
gh pr create --title "$PR_MESSAGE" \
--body "This PR create by github actions to updates the release notes." \
--base main \
--head "$PR_BRANCH" \
--label "auto-merge" \
--label "automated"
- name: Create Pull Request (Gitea)
if: ${{ steps.commit_and_push.outputs.changes_pushed == 'true' && matrix.product == 'easysearch' }}
uses: infinilabs/gitea-pr@v0
env:
https_proxy: http://${{ secrets.LOCAL_HOST }}:${{ secrets.LOCAL_PORT }}
with:
url: https://${{ secrets.HTTP_GIT_REPO}}
token: ${{ secrets.GITEA_TOKEN }}
path: ${{ env.PNAME }}
base: main
branch: ${{ env.PR_BRANCH}}
assignee : hardy
tea-version: 0.9.2
pr-label: "auto-merge, automated"
create-tag:
needs: generate-matrix
if: ${{ inputs.OPERATION == 'TAG' }}
name: Create TAG for ${{ matrix.product }}
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
max-parallel: 1
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup bootstrap
uses: ./containers/bootstrap
- name: Set up env for TAG
run: |
if [[ "${{ matrix.product }}" == "framework" ]]; then
VERSION=${{ inputs.PUBLISH_FRAMEWORK_VERSION }}
elif [[ "${{ matrix.product }}" == "easysearch" ]]; then
EZS_VER=${{ inputs.PUBLISH_EZS_VERSION }}
VER=${{ env.PUBLISH_VERSION }}
SUFFIX=${VER#*-}
if [[ "$VER" == *"-"* ]] && [[ "$EZS_VER" != *"-"* ]] && [[ -n "$SUFFIX" ]]; then
VERSION="${EZS_VER}-$SUFFIX"
else
VERSION=$EZS_VER
fi
elif [[ "${{ matrix.product }}" == "coco-app" ]]; then
VERSION=${{ inputs.PUBLISH_COCO_APP_VERSION }}
elif [[ "${{ matrix.product }}" == "coco-server" ]]; then
VERSION=${{ inputs.PUBLISH_COCO_VERSION }}
else
VERSION=${{ env.PUBLISH_VERSION }}
fi
if [[ -z "$VERSION" ]]; then
echo "Error: Version is empty for ${{ matrix.product }}"
exit 1
fi
echo "PNAME=${{ matrix.product }}" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Run connect in background (Easysearch only)
if: ${{ matrix.product == 'easysearch' }}
run: |
connect -c "$GITHUB_WORKSPACE/.net.json" >/dev/null 2>&1 &
echo "Connect started with pid $!"
sleep 5
- name: Checkout and create tag
run: |
if [[ "${{ matrix.product }}" == "easysearch" ]]; then
git clone ${{ secrets.SSH_GIT_REPO }}/${{ matrix.product }} $GITHUB_WORKSPACE/${{ matrix.product }}
else
git clone ${{ vars.GIT_SSH_REPO }}/${{ matrix.product }} $GITHUB_WORKSPACE/${{ matrix.product }}
fi
cd $GITHUB_WORKSPACE/${{ matrix.product }}
git config user.name github-actions
git config user.email github-actions@github.com
echo "Check tag and create tag for ${{ matrix.product }}"
PVER=$(echo "v$VERSION" | sed 's/-.*//')
tag_exists=$(git rev-parse --verify "refs/tags/$PVER" 2>/dev/null && echo true || echo false)
if [[ "$tag_exists" == "false" ]]; then
git tag -a $PVER -m "Release $PVER"
git push origin $PVER
sleep 10
else
echo "Tag $PVER already exists for ${{ matrix.product }}"
exit 0
fi
release-metadata:
if: ${{ inputs.OPERATION == 'RELEASE' }}
name: Update Release Metadata & .latest
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup bootstrap
uses: ./containers/bootstrap
- name: Update GitHub Variables
env:
GH_TOKEN: ${{ secrets.REPO_PAT }}
DO_PROD: ${{ inputs.PRODUCTS_PUBLISH }}
DO_EZS: ${{ inputs.EASYSEARCH_PUBLISH }}
DO_COCO: ${{ inputs.COCO_PUBLISH }}
run: |
VER=${{ inputs.PUBLISH_VERSION }}
EZS_VER=${{ inputs.PUBLISH_EZS_VERSION }}
COCO_APP_VER=${{ inputs.PUBLISH_COCO_APP_VERSION }}
COCO_VER=${{ inputs.PUBLISH_COCO_VERSION }}
# 1. Update Global Product Version (Console, Agent, Gateway...)
if [[ "$DO_PROD" == "true" ]]; then
if [[ ! -z "$VER" && "$VER" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-[a-zA-Z0-9_.-]+)?$ ]]; then
VER_CLEAN="${VER%%-*}"
echo "Updating GitHub release version to $VER_CLEAN"
gh variable set PUBLISH_VERSION --body "$VER_CLEAN"
else
echo "::warning:: Products publish selected but version invalid: $VER"
fi
else
echo "Skipping Products (Agent/Console) variable update."
fi
# 2. Update Easysearch Version
if [[ "$DO_EZS" == "true" ]]; then
if [[ ! -z "$EZS_VER" && "$EZS_VER" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-[a-zA-Z0-9_.-]+)?$ ]]; then
EZS_VER_CLEAN="${EZS_VER%%-*}"
echo "Updating GitHub release Easysearch version to $EZS_VER_CLEAN"
gh variable set EASYSEARCH_PUBLISH_VERSION --body "$EZS_VER_CLEAN"
fi
else
echo "Skipping Easysearch variable update."
fi
# 3. Update Coco Versions
if [[ "$DO_COCO" == "true" ]]; then
if [[ ! -z "$COCO_APP_VER" && "$COCO_APP_VER" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-[a-zA-Z0-9_.-]+)?$ ]]; then
COCO_APP_VER_CLEAN="${COCO_APP_VER%%-*}"
echo "Updating GitHub release Coco app version to $COCO_APP_VER_CLEAN"
gh variable set COCO_APP_PUBLISH_VERSION --body "$COCO_APP_VER_CLEAN"
fi
if [[ ! -z "$COCO_VER" && "$COCO_VER" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-[a-zA-Z0-9_.-]+)?$ ]]; then
COCO_VER_CLEAN="${COCO_VER%%-*}"
echo "Updating GitHub release Coco server version to $COCO_VER_CLEAN"
gh variable set COCO_PUBLISH_VERSION --body "$COCO_VER_CLEAN"
fi
else
echo "Skipping Coco variable update."
fi
- name: Update .latest file and upload to OSS
env:
DO_PROD: ${{ inputs.PRODUCTS_PUBLISH }}
DO_EZS: ${{ inputs.EASYSEARCH_PUBLISH }}
DO_COCO: ${{ inputs.COCO_PUBLISH }}
run: |
IN_VER=${{ inputs.PUBLISH_VERSION }}
IN_EZS_VER=${{ inputs.PUBLISH_EZS_VERSION }}
IN_COCO_APP_VER=${{ inputs.PUBLISH_COCO_APP_VERSION }}
IN_COCO_VER=${{ inputs.PUBLISH_COCO_VERSION }}
fname=".latest"
if [[ ! -f "/tmp/$fname" ]]; then
echo "Downloading current .latest from $RELEASE_URL/$fname..."
wget -q --show-progress --progress=bar:force:noscroll "$RELEASE_URL/$fname" -P /tmp
fi
if [[ "$DO_PROD" == "true" ]]; then
FINAL_PROD_VER="$IN_VER"
else
FINAL_PROD_VER=$(jq -r .console "/tmp/$fname")
echo "Products publish skipped, keeping existing version: $FINAL_PROD_VER"
fi
if [[ "$DO_EZS" == "true" ]]; then
SUFFIX=${IN_VER#*-}
if [[ "$IN_VER" == *"-"* ]] && [[ "$IN_EZS_VER" != *"-"* ]] && [[ -n "$SUFFIX" ]]; then
FINAL_EZS_VER="${IN_EZS_VER}-$SUFFIX"
else
FINAL_EZS_VER="$IN_EZS_VER"
fi
else
FINAL_EZS_VER=$(jq -r .easysearch "/tmp/$fname")
echo "Easysearch publish skipped, keeping existing version: $FINAL_EZS_VER"
fi
if [[ "$DO_COCO" == "true" ]]; then
SUFFIX=${IN_VER#*-}
if [[ "$IN_VER" == *"-"* ]] && [[ "$IN_COCO_APP_VER" != *"-"* ]] && [[ -n "$SUFFIX" ]]; then
FINAL_COCO_APP_VER="${IN_COCO_APP_VER}-$SUFFIX"
else
FINAL_COCO_APP_VER="$IN_COCO_APP_VER"
fi
if [[ "$IN_VER" == *"-"* ]] && [[ "$IN_COCO_VER" != *"-"* ]] && [[ -n "$SUFFIX" ]]; then
FINAL_COCO_VER="${IN_COCO_VER}-$SUFFIX"
else
FINAL_COCO_VER="$IN_COCO_VER"
fi
else
FINAL_COCO_APP_VER=$(jq -r '."coco-app"' "/tmp/$fname")
FINAL_COCO_VER=$(jq -r '."coco-server"' "/tmp/$fname")
echo "Coco publish skipped, keeping existing versions."
fi
echo "Updating local .latest file..."
jq --arg publish_version "$FINAL_PROD_VER" \
--arg easysearch_version "$FINAL_EZS_VER" \
--arg coco_app_version "$FINAL_COCO_APP_VER" \
--arg coco_version "$FINAL_COCO_VER" \
'.console=$publish_version | .gateway=$publish_version | .agent=$publish_version | ."coco-app"=$coco_app_version | ."coco-server"=$coco_version | .easysearch=$easysearch_version | .loadgen=$publish_version' \
"/tmp/$fname" > $GITHUB_WORKSPACE/$fname
if $GITHUB_WORKSPACE/scripts/version_compare "/tmp/$fname" "$GITHUB_WORKSPACE/$fname"; then
echo "Files are the same, no need to upload."
else
echo "Files are different, uploading to OSS..."
oss upload -c $GITHUB_WORKSPACE/.oss.yml -o -f $GITHUB_WORKSPACE/$fname
fi
- name: Update Easysearch .versions.json
if: ${{ inputs.EASYSEARCH_PUBLISH == true }}
env:
GH_TOKEN: ${{ secrets.REPO_PAT }}
EZS_VER: ${{ inputs.PUBLISH_EZS_VERSION }}
run: |
PNAME=easysearch
VERSIONS_FILE="$GITHUB_WORKSPACE/products/$PNAME/publish/.versions.json"
# Parse version and build number from format like "2.1.0-2661"
if [[ "$EZS_VER" =~ ^([0-9]+\.[0-9]+\.[0-9]+)-([0-9]+)$ ]]; then
VER_CLEAN="${BASH_REMATCH[1]}"
BUILD_NUM="${BASH_REMATCH[2]}"
elif [[ "$EZS_VER" =~ ^([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
VER_CLEAN="$EZS_VER"
BUILD_NUM=""
else
echo "::warning:: Invalid PUBLISH_EZS_VERSION format: $EZS_VER, skipping .versions.json update."
exit 0
fi
echo "Updating .versions.json for Easysearch $VER_CLEAN (build: $BUILD_NUM)"
DEFAULT_PLATFORMS='["linux-amd64","linux-arm64","mac-amd64","mac-arm64","windows-amd64"]'
if jq -e --arg ver "$VER_CLEAN" '.[$ver]' "$VERSIONS_FILE" > /dev/null 2>&1; then
echo "Version $VER_CLEAN exists, updating build_number to $BUILD_NUM"
UPDATED=$(jq --arg ver "$VER_CLEAN" --argjson bn "$BUILD_NUM" \
'.[$ver].build_number = $bn' "$VERSIONS_FILE")
else
echo "Version $VER_CLEAN not found, inserting new entry"
UPDATED=$(jq --arg ver "$VER_CLEAN" --argjson bn "$BUILD_NUM" \
--argjson platforms "$DEFAULT_PLATFORMS" \
'{($ver): {"platforms": $platforms, "build_number": $bn}} + .' \
"$VERSIONS_FILE")
fi
echo "$UPDATED" > "$VERSIONS_FILE"
PR_BRANCH="ci_release_ezs_versions_${VER_CLEAN}"
PR_MESSAGE="chore: update $PNAME .versions.json for $VER_CLEAN (build $BUILD_NUM)"
git config user.name github-actions
git config user.email github-actions@github.com
if git ls-remote --heads origin "$PR_BRANCH" | grep -q "$PR_BRANCH"; then
echo "Branch $PR_BRANCH already exists, deleting..."
git push origin --delete "$PR_BRANCH"
fi
git checkout -b "$PR_BRANCH"
git add "$VERSIONS_FILE"
if git diff --cached --quiet; then
echo "No changes to .versions.json, skipping PR."
else
# upload to oss
oss upload -c $GITHUB_WORKSPACE/.oss.yml -o -k $PNAME -f $VERSIONS_FILE
# auto commit pr for change
git commit -m "$PR_MESSAGE"
git push origin "$PR_BRANCH"
gh pr create --title "$PR_MESSAGE" \
--body "This PR was created by GitHub Actions to update the Easysearch versions metadata." \
--base main \
--head "$PR_BRANCH" \
--label "auto-merge" \
--label "automated"
fi
release-files:
if: ${{ inputs.OPERATION == 'RELEASE' }}
name: Update Release files from snapshot to stable
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup bootstrap
uses: ./containers/bootstrap
- name: Move products files from snapshot to stable
env:
DO_PROD: ${{ inputs.PRODUCTS_PUBLISH }}
DO_EZS: ${{ inputs.EASYSEARCH_PUBLISH }}
DO_COCO: ${{ inputs.COCO_PUBLISH }}
PROD_VER: ${{ inputs.PUBLISH_VERSION}}
EZS_VER: ${{ inputs.PUBLISH_EZS_VERSION}}
COCO_VER: ${{ inputs.PUBLISH_COCO_VERSION}}
COCO_APP_VER: ${{ inputs.PUBLISH_COCO_APP_VERSION}}
run: |
if [[ "$DO_PROD" == "true" ]]; then
for p in agent gateway console loadgen; do
echo "Move Products $p-${PROD_VER} from snapshot to stable"
oss move -p $p --prefix $p-${PROD_VER}
done
fi
- name: Move easysearch files from snapshot to stable
env:
DO_PROD: ${{ inputs.PRODUCTS_PUBLISH }}
DO_EZS: ${{ inputs.EASYSEARCH_PUBLISH }}
DO_COCO: ${{ inputs.COCO_PUBLISH }}
PROD_VER: ${{ inputs.PUBLISH_VERSION}}
EZS_VER: ${{ inputs.PUBLISH_EZS_VERSION}}
COCO_VER: ${{ inputs.PUBLISH_COCO_VERSION}}
COCO_APP_VER: ${{ inputs.PUBLISH_COCO_APP_VERSION}}
run: |
# Easysearch
p=easysearch
if [[ "$DO_EZS" == "true" ]]; then
echo "Move $p-${EZS_VER} from snapshot to stable"
oss move -p $p --prefix $p-${EZS_VER}
echo "Move $p-${EZS_VER} bundle from snapshot/bundle to stable/bundle"
oss move -p $p -s bundle --prefix $p-${EZS_VER}
fi
- name: Move coco files from snapshot to stable
env:
DO_PROD: ${{ inputs.PRODUCTS_PUBLISH }}
DO_EZS: ${{ inputs.EASYSEARCH_PUBLISH }}
DO_COCO: ${{ inputs.COCO_PUBLISH }}
PROD_VER: ${{ inputs.PUBLISH_VERSION}}
EZS_VER: ${{ inputs.PUBLISH_EZS_VERSION}}
COCO_VER: ${{ inputs.PUBLISH_COCO_VERSION}}
COCO_APP_VER: ${{ inputs.PUBLISH_COCO_APP_VERSION}}
run: |
if [[ "$DO_COCO" == "true" ]]; then
echo "Move Coco from snapshot to stable"
fi
release-official-website:
needs: [release-metadata, release-files]
if: ${{ inputs.OPERATION == 'RELEASE' }}
name: Update Official Website
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup bootstrap
uses: ./containers/bootstrap
- name: Install Python dependencies
run: pip install requests pyyaml
- name: Run connect in background
run: |
connect -c "$GITHUB_WORKSPACE/.net.json" >/dev/null 2>&1 &
echo "Connect started with pid $!"
sleep 5
- name: Checkout official-website-cn
timeout-minutes: 30
run: |
git clone --depth 1 --filter=blob:none --sparse ${{ secrets.SSH_GIT_REPO }}/official-website-cn $GITHUB_WORKSPACE/official-website-cn
cd $GITHUB_WORKSPACE/official-website-cn
git sparse-checkout set data
echo "Checkout repo $(git log -1 --pretty=format:'%h, %ad, %an, %s')"
git config user.name github-actions
git config user.email github-actions@github.com
- name: Create branch and update version data
env:
DO_PROD: ${{ inputs.PRODUCTS_PUBLISH }}
DO_EZS: ${{ inputs.EASYSEARCH_PUBLISH }}
DO_COCO: ${{ inputs.COCO_PUBLISH }}
PROD_VER: ${{ inputs.PUBLISH_VERSION }}
EZS_VER: ${{ inputs.PUBLISH_EZS_VERSION }}
COCO_VER: ${{ inputs.PUBLISH_COCO_VERSION }}
COCO_APP_VER: ${{ inputs.PUBLISH_COCO_APP_VERSION }}
run: |
BUILD_DATE=$(date +'%Y-%m-%d')
PR_BRANCH="ci_release_website_$(date +'%Y%m%d_%H%M%S')"
PR_MESSAGE="chore: update product versions for release"
echo "PR_BRANCH=$PR_BRANCH" >> $GITHUB_ENV
echo "PR_MESSAGE=$PR_MESSAGE" >> $GITHUB_ENV
cd $GITHUB_WORKSPACE/official-website-cn
if git ls-remote --heads origin "$PR_BRANCH" | grep -q "$PR_BRANCH"; then
echo "Branch $PR_BRANCH found. Deleting remote branch..."
git push origin --delete "$PR_BRANCH"
fi
git checkout -b "$PR_BRANCH"
run_update() {
local pname=$1 full_ver=$2
local ver_main="${full_ver%%-*}"
local build_num="${full_ver#*-}"
CODE_BASE_PATH="$GITHUB_WORKSPACE/official-website-cn" \
VERSION="$ver_main" BUILD_NUMBER="$build_num" \
BUILD_DATE="$BUILD_DATE" PNAME="$pname" \
LATEST_URL="https://release.infinilabs.com/.latest" \
python3 $GITHUB_WORKSPACE/scripts/update_version.py
}
SUFFIX="${PROD_VER#*-}"
if [[ "$DO_PROD" == "true" ]]; then
for p in agent gateway console loadgen; do
run_update "$p" "$PROD_VER"
done
fi
if [[ "$DO_EZS" == "true" ]]; then
EZS_FULL_VER="$EZS_VER"
if [[ "$PROD_VER" == *"-"* ]] && [[ "$EZS_VER" != *"-"* ]] && [[ -n "$SUFFIX" ]]; then
EZS_FULL_VER="${EZS_VER}-$SUFFIX"
fi
run_update "easysearch" "$EZS_FULL_VER"
fi
if [[ "$DO_COCO" == "true" ]]; then
COCO_APP_FULL_VER="$COCO_APP_VER"
if [[ "$PROD_VER" == *"-"* ]] && [[ "$COCO_APP_VER" != *"-"* ]] && [[ -n "$SUFFIX" ]]; then
COCO_APP_FULL_VER="${COCO_APP_VER}-$SUFFIX"
fi
run_update "coco-app" "$COCO_APP_FULL_VER"
COCO_FULL_VER="$COCO_VER"
if [[ "$PROD_VER" == *"-"* ]] && [[ "$COCO_VER" != *"-"* ]] && [[ -n "$SUFFIX" ]]; then
COCO_FULL_VER="${COCO_VER}-$SUFFIX"
fi
run_update "coco-server" "$COCO_FULL_VER"
fi
- name: Commit and push
id: commit_and_push
run: |
cd $GITHUB_WORKSPACE/official-website-cn
if [[ -n $(git status --porcelain) ]]; then
echo "✅ Changes detected. Proceeding with commit and push..."
git add -A
git commit -m "$PR_MESSAGE"
git push origin "$PR_BRANCH"
echo "changes_pushed=true" >> $GITHUB_OUTPUT
else
echo "🤷 No changes detected. Skipping commit and push."
echo "changes_pushed=false" >> $GITHUB_OUTPUT
fi
git remote set-url origin https://${{ secrets.HTTP_GIT_REPO }}/infini/official-website-cn
- name: Create Pull Request (Gitea)
if: ${{ steps.commit_and_push.outputs.changes_pushed == 'true' }}
uses: infinilabs/gitea-pr@v0
env:
https_proxy: http://${{ secrets.LOCAL_HOST }}:${{ secrets.LOCAL_PORT }}
with:
url: https://${{ secrets.HTTP_GIT_REPO }}
token: ${{ secrets.GITEA_TOKEN }}
path: official-website-cn
base: master
branch: ${{ env.PR_BRANCH }}
assignee: hardy
tea-version: 0.9.2
pr-label: "auto-merge, automated"
publish-coco-website:
needs: release-metadata
if: ${{ inputs.OPERATION == 'RELEASE' && inputs.COCO_PUBLISH == true }}
name: Publish Coco Website
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Publish Website Tag
run: |
COCO_VER=${{ inputs.PUBLISH_COCO_VERSION }}
git clone ${{ vars.GIT_SSH_REPO }}/coco-website $GITHUB_WORKSPACE/coco-website
cd $GITHUB_WORKSPACE/coco-website
git config user.name github-actions
git config user.email github-actions@github.com
PVER=$(echo "v$COCO_VER" | sed 's/-.*//')
if git rev-parse --verify "refs/tags/$PVER" >/dev/null 2>&1; then
echo "Tag $PVER already exists for coco-website"
else
git tag -a $PVER -m "Release $PVER"
git push origin $PVER
echo "Tag $PVER created."
fi
notify_on_failure:
runs-on: ubuntu-latest
needs: [create-pr, create-tag, release-metadata, publish-coco-website, release-official-website]
if: failure()
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Notify message via feishu
env:
FEISHU_BOT_URL: ${{ secrets.FEISHU_BOT_WEBHOOK_URL }}
REPO_NAME: ${{ github.repository }}
WORKFLOW_NAME: ${{ github.workflow }}
RUN_ID: ${{ github.run_id }}
ACTOR: ${{ github.triggering_actor }}
SERVER_URL: ${{ github.server_url }}
run: $GITHUB_WORKSPACE/scripts/feishu_message.sh