Publish Analysis Plugins #438
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Analysis Plugins | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| RELEASE_URL: ${{ vars.RELEASE_URL }} | |
| JAVA_DISTRIBUTION: ${{ vars.JAVA_DISTRIBUTION}} | |
| MAVEN_VERSION: ${{ vars.MAVEN_VERSION }} | |
| MAVEN_DOWNLOAD_URL: ${{ vars.MAVEN_DOWNLOAD_URL }} | |
| 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 }} | |
| on: | |
| schedule: | |
| - cron: '30 16 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| REPUBLISH_TNAME: | |
| description: 'Overrides Republish Product' | |
| required: false | |
| type: choice | |
| options: | |
| - elasticsearch | |
| - opensearch | |
| default: 'elasticsearch' | |
| REPUBLISH_PRODUCT: | |
| description: 'Overrides Republish Product' | |
| required: false | |
| type: choice | |
| options: | |
| - analysis-ik | |
| - analysis-pinyin | |
| - analysis-stconvert | |
| default: 'analysis-ik' | |
| REPUBLISH_VERSION: | |
| description: 'Overrides Republish version' | |
| required: false | |
| default: '7.10.2' | |
| JAVA_VERSION: | |
| description: 'Overrides Java Version ' | |
| required: true | |
| default: '11' | |
| jobs: | |
| publish_versions_with_jdk_input: | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| name: Publish ${{ matrix.plugins }} for ${{ matrix.product }} @ ${{inputs.REPUBLISH_VERSION}} with input jdk ${{ inputs.JAVA_VERSION }} | |
| runs-on: ubuntu-latest | |
| env: | |
| PNAME: ${{ matrix.plugins }} | |
| TNAME: ${{ matrix.product }} | |
| JAVA_VERSION: ${{ inputs.JAVA_VERSION }} | |
| strategy: | |
| matrix: | |
| plugins: | |
| - ${{ inputs.REPUBLISH_PRODUCT }} | |
| product: | |
| - ${{ inputs.REPUBLISH_TNAME }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Setup bootstrap | |
| uses: ./containers/bootstrap | |
| - name: Checkout ${{ matrix.plugins }} code | |
| uses: actions/checkout@v7 | |
| with: | |
| repository: ${{ vars.GIT_REPO }}/${{ env.PNAME }} | |
| ref: master | |
| path: ${{ env.PNAME }} | |
| - name: Set up java toolchain with ${{ env.JAVA_DISTRIBUTION }}-${{ env.JAVA_VERSION }} | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: ${{ env.JAVA_DISTRIBUTION }} | |
| java-version: ${{ env.JAVA_VERSION }} | |
| cache: maven | |
| - name: Set up maven with ${{ env.MAVEN_VERSION }} | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: ${{ env.MAVEN_VERSION }} | |
| - name: Prepare build code | |
| run: | | |
| echo "Build $PNAME start..." | |
| mvn -v | |
| - name: Set build ${{ matrix.plugins }} for ${{ matrix.product }} versions | |
| if: ${{ contains(fromJSON('["11", "17"]'), inputs.JAVA_VERSION) }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_API_URL: https://api.github.com | |
| run: | | |
| fetch_versions() { | |
| # $1: repo slug (e.g., "owner/repo") and $2: version regex | |
| curl -H "Authorization: Bearer $GH_TOKEN" "$GITHUB_API_URL/repos/$1/releases?per_page=10" \ | |
| | jq -r --arg regex "$2" ' | |
| .[] | | |
| select( | |
| .prerelease == false and | |
| .draft == false and | |
| (.tag_name | test($regex)) | |
| ) | | |
| .tag_name | sub("^v"; "")' | |
| } | |
| if [[ $TNAME == "elasticsearch" ]] ; then | |
| LATEST_VERSION=$(fetch_versions "elastic/$TNAME" "^v[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$") | |
| echo "$LATEST_VERSION" > /tmp/all_versions | |
| else | |
| LATEST_VERSION=$(fetch_versions "$TNAME-project/$TNAME" "^[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$") | |
| echo "$LATEST_VERSION" > /tmp/all_versions | |
| fi | |
| [[ "${{ matrix.product }}" == "${{ inputs.REPUBLISH_TNAME }}" && -n "${{ inputs.REPUBLISH_VERSION }}" ]] && echo "${{ inputs.REPUBLISH_VERSION }}" > /tmp/all_versions | |
| # filter versions | |
| > /tmp/versions | |
| if [[ $TNAME == "elasticsearch" ]] ; then | |
| while IFS= read -r ver; do | |
| MAJOR_VERSION=$(echo "$ver" | cut -d '.' -f 1) | |
| if [[ "$MAJOR_VERSION" -lt 9 ]]; then | |
| echo "$ver" >> /tmp/versions | |
| fi | |
| done < /tmp/all_versions | |
| else | |
| while IFS= read -r ver; do | |
| MAJOR_VERSION=$(echo "$ver" | cut -d '.' -f 1) | |
| if [[ "$MAJOR_VERSION" -lt 3 ]]; then | |
| echo "$ver" >> /tmp/versions | |
| fi | |
| done < /tmp/all_versions | |
| fi | |
| cat /tmp/versions | |
| - name: Set build ${{ matrix.plugins }} for ${{ matrix.product }} versions | |
| if: ${{ contains(fromJSON('["21", "23"]'), inputs.JAVA_VERSION) }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_API_URL: https://api.github.com | |
| run: | | |
| fetch_versions() { | |
| # $1: repo slug (e.g., "owner/repo") and $2: version regex | |
| curl -H "Authorization: Bearer $GH_TOKEN" "$GITHUB_API_URL/repos/$1/releases?per_page=10" \ | |
| | jq -r --arg regex "$2" ' | |
| .[] | | |
| select( | |
| .prerelease == false and | |
| .draft == false and | |
| (.tag_name | test($regex)) | |
| ) | | |
| .tag_name | sub("^v"; "")' | |
| } | |
| if [[ $TNAME == "elasticsearch" ]] ; then | |
| LATEST_VERSION=$(fetch_versions "elastic/$TNAME" "^v[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$") | |
| echo "$LATEST_VERSION" > /tmp/all_versions | |
| else | |
| LATEST_VERSION=$(fetch_versions "$TNAME-project/$TNAME" "^[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$") | |
| echo "$LATEST_VERSION" > /tmp/all_versions | |
| fi | |
| [[ "${{ matrix.product }}" == "${{ inputs.REPUBLISH_TNAME }}" && -n "${{ inputs.REPUBLISH_VERSION }}" ]] && echo "${{ inputs.REPUBLISH_VERSION }}" > /tmp/all_versions | |
| # filter versions | |
| > /tmp/versions | |
| if [[ $TNAME == "elasticsearch" ]] ; then | |
| while IFS= read -r ver; do | |
| MAJOR_VERSION=$(echo "$ver" | cut -d '.' -f 1) | |
| if [[ "$MAJOR_VERSION" -ge 9 ]]; then | |
| echo "$ver" >> /tmp/versions | |
| fi | |
| done < /tmp/all_versions | |
| else | |
| while IFS= read -r ver; do | |
| MAJOR_VERSION=$(echo "$ver" | cut -d '.' -f 1) | |
| if [[ "$MAJOR_VERSION" -ge 3 ]]; then | |
| echo "$ver" >> /tmp/versions | |
| fi | |
| done < /tmp/all_versions | |
| fi | |
| cat /tmp/versions | |
| - name: Build need publish ${{ matrix.plugins }} for ${{ matrix.product }} versions | |
| run: | | |
| cd $GITHUB_WORKSPACE/$PNAME | |
| echo Check need publish version at $PWD with branch $(git branch --show-current) | |
| while IFS= read -r ver; do | |
| # Check published history | |
| URL=$RELEASE_URL/$PNAME/stable/$TNAME-$PNAME-$ver.zip | |
| HTTP_STATUS=$(curl -s -I -o /dev/null -w "%{http_code}" "$URL" || true) | |
| if [[ "$HTTP_STATUS" =~ ^2[0-9]{2}$ ]]; then | |
| if [[ "${{ matrix.product }}" == "${{ inputs.REPUBLISH_TNAME }}" && -n "${{ inputs.REPUBLISH_VERSION }}" ]]; then | |
| echo "Version $ver already published, overwrite..." | |
| else | |
| echo "Version $ver already published, skipping..." | |
| continue | |
| fi | |
| fi | |
| # Build when not publish | |
| if [[ "${ver%%.*}" -lt 9 ]]; then | |
| if [[ "$TNAME" == "elasticsearch" ]]; then | |
| minor="$(echo "$ver" | cut -d. -f2)" | |
| target_branch_specific="${ver%%.*}.${minor}" | |
| target_branch_generic="${ver%%.*}.x" | |
| if git ls-remote --exit-code --heads origin "$target_branch_specific" &>/dev/null; then | |
| echo "Specific branch $target_branch_specific found. Fetching and checking out." | |
| git fetch origin "$target_branch_specific" && git checkout "$target_branch_specific" | |
| else | |
| echo "Specific branch $target_branch_specific not found. Fetching and checking out generic branch $target_branch_generic." | |
| git fetch origin "$target_branch_generic" && git checkout "$target_branch_generic" | |
| fi | |
| else | |
| git fetch origin "open-${ver%%.*}.x" && git checkout "open-${ver%%.*}.x" | |
| fi | |
| fi | |
| echo "Current build for $TNAME version [ $ver ] with branch $(git rev-parse --abbrev-ref HEAD)" | |
| if [[ "${ver%%.*}" -lt 8 ]] && [[ "$TNAME" == "elasticsearch" ]]; then | |
| echo mvn package -DskipTests -D$TNAME.version=$ver | |
| mvn package -DskipTests -D$TNAME.version=$ver | |
| else | |
| echo mvn package -pl $TNAME -am -DskipTests -D$TNAME.version=$ver | |
| mvn package -pl $TNAME -am -DskipTests -D$TNAME.version=$ver | |
| fi | |
| done < "/tmp/versions" | |
| - name: Upload ${{ matrix.plugins }} for ${{ matrix.product }} all verion files | |
| run: | | |
| target_dirs=$(find $GITHUB_WORKSPACE/$PNAME -maxdepth 3 -name "releases" -print) | |
| [[ -z "$target_dirs" ]] && exit 0 || echo "Found target directories: $target_dirs" | |
| # 遍历所有目标目录 | |
| while IFS= read -r target_dir; do | |
| # 查找当前目录下所有zip文件 | |
| find "$target_dir" -maxdepth 1 -name "*.zip" -print0 | while IFS= read -r -d $'\0' zip_file; do | |
| echo "Uploading ${zip_file##*/} with path $zip_file..." | |
| (cd "$(dirname "$zip_file")" && sha512sum "$(basename "$zip_file")" > "$(basename "$zip_file").sha512") | |
| oss upload -c $GITHUB_WORKSPACE/.oss.yml -o -k $PNAME/stable -f "$zip_file" | |
| oss upload -c $GITHUB_WORKSPACE/.oss.yml -o -k $PNAME/stable -f "$zip_file.sha512" | |
| done | |
| done <<< "$target_dirs" | |
| publish_versions_with_jdk_17: | |
| if: ${{ github.event_name != 'workflow_dispatch' }} | |
| name: Publish ${{ matrix.plugins }} for ${{ matrix.product }} versions with JDK 17 | |
| runs-on: ubuntu-latest | |
| env: | |
| PNAME: ${{ matrix.plugins }} | |
| TNAME: ${{ matrix.product }} | |
| JAVA_VERSION: ${{ vars.JAVA_VERSION_17 }} | |
| strategy: | |
| matrix: | |
| plugins: | |
| - analysis-ik | |
| - analysis-pinyin | |
| - analysis-stconvert | |
| product: | |
| - elasticsearch | |
| - opensearch | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Setup bootstrap | |
| uses: ./containers/bootstrap | |
| - name: Checkout ${{ matrix.plugins }} code | |
| uses: actions/checkout@v7 | |
| with: | |
| repository: ${{ vars.GIT_REPO }}/${{ env.PNAME }} | |
| ref: master | |
| path: ${{ env.PNAME }} | |
| - name: Set up java toolchain with ${{ env.JAVA_DISTRIBUTION }}-${{ env.JAVA_VERSION }} | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: ${{ env.JAVA_DISTRIBUTION }} | |
| java-version: ${{ env.JAVA_VERSION }} | |
| cache: maven | |
| - name: Set up maven with ${{ env.MAVEN_VERSION }} | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: ${{ env.MAVEN_VERSION }} | |
| - name: Prepare build code | |
| run: | | |
| echo "Build $PNAME start..." | |
| mvn -v | |
| - name: Set build ${{ matrix.plugins }} for ${{ matrix.product }} versions | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_API_URL: https://api.github.com | |
| run: | | |
| fetch_versions() { | |
| # $1: repo slug (e.g., "owner/repo") and $2: version regex | |
| curl -H "Authorization: Bearer $GH_TOKEN" "$GITHUB_API_URL/repos/$1/releases?per_page=10" \ | |
| | jq -r --arg regex "$2" ' | |
| .[] | | |
| select( | |
| .prerelease == false and | |
| .draft == false and | |
| (.tag_name | test($regex)) | |
| ) | | |
| .tag_name | sub("^v"; "")' | |
| } | |
| if [[ $TNAME == "elasticsearch" ]] ; then | |
| LATEST_VERSION=$(fetch_versions "elastic/$TNAME" "^v[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$") | |
| echo "$LATEST_VERSION" > /tmp/all_versions | |
| else | |
| LATEST_VERSION=$(fetch_versions "$TNAME-project/$TNAME" "^[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$") | |
| echo "$LATEST_VERSION" > /tmp/all_versions | |
| fi | |
| [[ "${{ matrix.product }}" == "${{ inputs.REPUBLISH_TNAME }}" && -n "${{ inputs.REPUBLISH_VERSION }}" ]] && echo "${{ inputs.REPUBLISH_VERSION }}" > /tmp/all_versions | |
| # filter versions | |
| > /tmp/versions | |
| if [[ $TNAME == "elasticsearch" ]] ; then | |
| while IFS= read -r ver; do | |
| MAJOR_VERSION=$(echo "$ver" | cut -d '.' -f 1) | |
| if [[ "$MAJOR_VERSION" -lt 9 ]]; then | |
| echo "$ver" >> /tmp/versions | |
| fi | |
| done < /tmp/all_versions | |
| else | |
| while IFS= read -r ver; do | |
| MAJOR_VERSION=$(echo "$ver" | cut -d '.' -f 1) | |
| if [[ "$MAJOR_VERSION" -lt 3 ]]; then | |
| echo "$ver" >> /tmp/versions | |
| fi | |
| done < /tmp/all_versions | |
| fi | |
| cat /tmp/versions | |
| - name: Build need publish ${{ matrix.plugins }} for ${{ matrix.product }} versions | |
| run: | | |
| cd $GITHUB_WORKSPACE/$PNAME | |
| echo Check need publish version at $PWD with branch $(git branch --show-current) | |
| while IFS= read -r ver; do | |
| # Check published history | |
| URL=$RELEASE_URL/$PNAME/stable/$TNAME-$PNAME-$ver.zip | |
| HTTP_STATUS=$(curl -s -I -o /dev/null -w "%{http_code}" "$URL" || true) | |
| if [[ "$HTTP_STATUS" =~ ^2[0-9]{2}$ ]]; then | |
| if [[ "${{ matrix.product }}" == "${{ inputs.REPUBLISH_TNAME }}" && -n "${{ inputs.REPUBLISH_VERSION }}" ]]; then | |
| echo "Version $ver already published, overwrite..." | |
| else | |
| echo "Version $ver already published, skipping..." | |
| continue | |
| fi | |
| fi | |
| # Build when not publish | |
| if [[ "${ver%%.*}" -lt 9 ]]; then | |
| if [[ "$TNAME" == "elasticsearch" ]]; then | |
| minor="$(echo "$ver" | cut -d. -f2)" | |
| target_branch_specific="${ver%%.*}.${minor}" | |
| target_branch_generic="${ver%%.*}.x" | |
| if git ls-remote --exit-code --heads origin "$target_branch_specific" &>/dev/null; then | |
| echo "Specific branch $target_branch_specific found. Fetching and checking out." | |
| git fetch origin "$target_branch_specific" && git checkout "$target_branch_specific" | |
| else | |
| echo "Specific branch $target_branch_specific not found. Fetching and checking out generic branch $target_branch_generic." | |
| git fetch origin "$target_branch_generic" && git checkout "$target_branch_generic" | |
| fi | |
| else | |
| git fetch origin "open-${ver%%.*}.x" && git checkout "open-${ver%%.*}.x" | |
| fi | |
| fi | |
| echo "Current build for $TNAME version [ $ver ] with branch $(git rev-parse --abbrev-ref HEAD)" | |
| if [[ "${ver%%.*}" -lt 8 ]] && [[ "$TNAME" == "elasticsearch" ]]; then | |
| echo mvn package -DskipTests -D$TNAME.version=$ver | |
| mvn package -DskipTests -D$TNAME.version=$ver | |
| else | |
| echo mvn package -pl $TNAME -am -DskipTests -D$TNAME.version=$ver | |
| mvn package -pl $TNAME -am -DskipTests -D$TNAME.version=$ver | |
| fi | |
| done < "/tmp/versions" | |
| - name: Upload ${{ matrix.plugins }} for ${{ matrix.product }} all verion files | |
| run: | | |
| target_dirs=$(find $GITHUB_WORKSPACE/$PNAME -maxdepth 3 -name "releases" -print) | |
| [[ -z "$target_dirs" ]] && exit 0 || echo "Found target directories: $target_dirs" | |
| # 遍历所有目标目录 | |
| while IFS= read -r target_dir; do | |
| # 查找当前目录下所有zip文件 | |
| find "$target_dir" -maxdepth 1 -name "*.zip" -print0 | while IFS= read -r -d $'\0' zip_file; do | |
| echo "Uploading ${zip_file##*/} with path $zip_file..." | |
| (cd "$(dirname "$zip_file")" && sha512sum "$(basename "$zip_file")" > "$(basename "$zip_file").sha512") | |
| oss upload -c $GITHUB_WORKSPACE/.oss.yml -o -k $PNAME/stable -f "$zip_file" | |
| oss upload -c $GITHUB_WORKSPACE/.oss.yml -o -k $PNAME/stable -f "$zip_file.sha512" | |
| done | |
| done <<< "$target_dirs" | |
| publish_versions_with_jdk_21: | |
| if: ${{ github.event_name != 'workflow_dispatch' }} | |
| name: Publish ${{ matrix.plugins }} for ${{ matrix.product }} versions with JDK 21 | |
| runs-on: ubuntu-latest | |
| env: | |
| PNAME: ${{ matrix.plugins }} | |
| TNAME: ${{ matrix.product }} | |
| JAVA_VERSION: ${{ vars.JAVA_VERSION_21 }} | |
| strategy: | |
| matrix: | |
| plugins: | |
| - analysis-ik | |
| - analysis-pinyin | |
| - analysis-stconvert | |
| product: | |
| - elasticsearch | |
| - opensearch | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Setup bootstrap | |
| uses: ./containers/bootstrap | |
| - name: Checkout ${{ matrix.plugins }} code | |
| uses: actions/checkout@v7 | |
| with: | |
| repository: ${{ vars.GIT_REPO }}/${{ env.PNAME }} | |
| ref: master | |
| path: ${{ env.PNAME }} | |
| - name: Set up java toolchain with ${{ env.JAVA_DISTRIBUTION }}-${{ env.JAVA_VERSION }} | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: ${{ env.JAVA_DISTRIBUTION }} | |
| java-version: ${{ env.JAVA_VERSION }} | |
| cache: maven | |
| - name: Set up maven with ${{ env.MAVEN_VERSION }} | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: ${{ env.MAVEN_VERSION }} | |
| - name: Prepare build code | |
| run: | | |
| echo "Build $PNAME start..." | |
| mvn -v | |
| - name: Set build ${{ matrix.plugins }} for ${{ matrix.product }} versions | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_API_URL: https://api.github.com | |
| run: | | |
| fetch_versions() { | |
| # $1: repo slug (e.g., "owner/repo") and $2: version regex | |
| curl -H "Authorization: Bearer $GH_TOKEN" "$GITHUB_API_URL/repos/$1/releases?per_page=10" \ | |
| | jq -r --arg regex "$2" ' | |
| .[] | | |
| select( | |
| .prerelease == false and | |
| .draft == false and | |
| (.tag_name | test($regex)) | |
| ) | | |
| .tag_name | sub("^v"; "")' | |
| } | |
| if [[ $TNAME == "elasticsearch" ]] ; then | |
| LATEST_VERSION=$(fetch_versions "elastic/$TNAME" "^v[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$") | |
| echo "$LATEST_VERSION" > /tmp/all_versions | |
| else | |
| LATEST_VERSION=$(fetch_versions "$TNAME-project/$TNAME" "^[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+)?$") | |
| echo "$LATEST_VERSION" > /tmp/all_versions | |
| fi | |
| if [[ "${{ matrix.product }}" == "${{ inputs.REPUBLISH_TNAME }}" && -n "${{ inputs.REPUBLISH_VERSION }}" ]] ; then | |
| echo "${{ inputs.REPUBLISH_VERSION }}" > /tmp/all_versions | |
| echo "Republishing ${{ inputs.REPUBLISH_VERSION }}" | |
| fi | |
| # filter versions | |
| > /tmp/versions | |
| if [[ $TNAME == "elasticsearch" ]] ; then | |
| while IFS= read -r ver; do | |
| MAJOR_VERSION=$(echo "$ver" | cut -d '.' -f 1) | |
| if [[ "$MAJOR_VERSION" -ge 9 ]]; then | |
| echo "$ver" >> /tmp/versions | |
| fi | |
| done < /tmp/all_versions | |
| else | |
| while IFS= read -r ver; do | |
| MAJOR_VERSION=$(echo "$ver" | cut -d '.' -f 1) | |
| if [[ "$MAJOR_VERSION" -ge 3 ]]; then | |
| echo "$ver" >> /tmp/versions | |
| fi | |
| done < /tmp/all_versions | |
| fi | |
| cat /tmp/versions | |
| - name: Build need publish ${{ matrix.plugins }} for ${{ matrix.product }} versions | |
| run: | | |
| cd $GITHUB_WORKSPACE/$PNAME | |
| echo Check need publish version at $PWD with branch $(git branch --show-current) | |
| while IFS= read -r ver; do | |
| # Check published history | |
| URL=$RELEASE_URL/$PNAME/stable/$TNAME-$PNAME-$ver.zip | |
| HTTP_STATUS=$(curl -s -I -o /dev/null -w "%{http_code}" "$URL" || true) | |
| if [[ "$HTTP_STATUS" =~ ^2[0-9]{2}$ ]]; then | |
| if [[ "${{ matrix.product }}" == "${{ inputs.REPUBLISH_TNAME }}" && -n "${{ inputs.REPUBLISH_VERSION }}" ]]; then | |
| echo "Version $ver already published, overwrite..." | |
| else | |
| echo "Version $ver already published, skipping..." | |
| continue | |
| fi | |
| fi | |
| # Build when not publish | |
| if [[ "${ver%%.*}" -lt 9 ]]; then | |
| if [[ "$TNAME" == "elasticsearch" ]]; then | |
| minor="$(echo "$ver" | cut -d. -f2)" | |
| target_branch_specific="${ver%%.*}.${minor}" | |
| target_branch_generic="${ver%%.*}.x" | |
| if git ls-remote --exit-code --heads origin "$target_branch_specific" &>/dev/null; then | |
| echo "Specific branch $target_branch_specific found. Fetching and checking out." | |
| git fetch origin "$target_branch_specific" && git checkout "$target_branch_specific" | |
| else | |
| echo "Specific branch $target_branch_specific not found. Fetching and checking out generic branch $target_branch_generic." | |
| git fetch origin "$target_branch_generic" && git checkout "$target_branch_generic" | |
| fi | |
| else | |
| git fetch origin "open-${ver%%.*}.x" && git checkout "open-${ver%%.*}.x" | |
| fi | |
| fi | |
| echo "Current build for $TNAME version [ $ver ] with branch $(git rev-parse --abbrev-ref HEAD)" | |
| if [[ "${ver%%.*}" -lt 8 ]] && [[ "$TNAME" == "elasticsearch" ]]; then | |
| echo mvn package -DskipTests -D$TNAME.version=$ver | |
| mvn package -DskipTests -D$TNAME.version=$ver | |
| else | |
| echo mvn package -pl $TNAME -am -DskipTests -D$TNAME.version=$ver | |
| mvn package -pl $TNAME -am -DskipTests -D$TNAME.version=$ver | |
| fi | |
| done < "/tmp/versions" | |
| - name: Upload ${{ matrix.plugins }} for ${{ matrix.product }} all verion files | |
| run: | | |
| target_dirs=$(find $GITHUB_WORKSPACE/$PNAME -maxdepth 3 -name "releases" -print) | |
| [[ -z "$target_dirs" ]] && exit 0 || echo "Found target directories: $target_dirs" | |
| # 遍历所有目标目录 | |
| while IFS= read -r target_dir; do | |
| # 查找当前目录下所有zip文件 | |
| find "$target_dir" -maxdepth 1 -name "*.zip" -print0 | while IFS= read -r -d $'\0' zip_file; do | |
| echo "Uploading ${zip_file##*/} with path $zip_file..." | |
| (cd "$(dirname "$zip_file")" && sha512sum "$(basename "$zip_file")" > "$(basename "$zip_file").sha512") | |
| oss upload -c $GITHUB_WORKSPACE/.oss.yml -o -k $PNAME/stable -f "$zip_file" | |
| oss upload -c $GITHUB_WORKSPACE/.oss.yml -o -k $PNAME/stable -f "$zip_file.sha512" | |
| done | |
| done <<< "$target_dirs" | |
| notify_on_failure: | |
| runs-on: ubuntu-latest | |
| needs: [publish_versions_with_jdk_input, publish_versions_with_jdk_17, publish_versions_with_jdk_21] | |
| if: failure() | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - 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 |