Skip to content

Products Release Notes and Tag #125

Products Release Notes and Tag

Products Release Notes and Tag #125

Workflow file for this run

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