This is an automated email from the ASF dual-hosted git repository.

adonisling pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/doris-thirdparty.git


The following commit(s) were added to refs/heads/main by this push:
     new d2ab259  [chore](github) Add a workflow to build libraries 
automatically (#13)
d2ab259 is described below

commit d2ab259d8c1dd5a70eb6157da2bfe14ad3407aee
Author: Adonis Ling <adonis0...@gmail.com>
AuthorDate: Mon Nov 21 11:41:29 2022 +0800

    [chore](github) Add a workflow to build libraries automatically (#13)
    
    Features
    
    1. The workflow will trigger the build process if it detects some changes 
was made for third-party libraries in apache/doris and it will be scheduled 
every 30 minutes.
    2. Release the prebuilts automatically.
---
 .github/workflows/build.yml | 214 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 214 insertions(+)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..f2adb27
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,214 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Build
+
+on:
+  schedule:
+    - cron: '*/30 * * * *'
+
+jobs:
+  prerelease:
+    name: Prerelease
+    runs-on: macos-latest
+    env:
+      GH_REPO: ${{ github.repository }}
+      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    permissions:
+      contents: write
+    outputs:
+      should_release: ${{ steps.check_diff.outputs.should_release }}
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          repository: 'apache/doris'
+          fetch-depth: 0
+
+      - name: Check Diff
+        id: check_diff
+        run: |
+          if [[ -z "$(gh release list)" ]] ||
+              ! gh release list | awk -F "\t" '{ if ($3 == "automation") exit 
0; else exit 1 }'; then
+            gh release create -t 'Apache Doris Third Party Prebuilt' automation
+          fi
+          last_version="$(gh release view automation | sed -n -E 's/Doris 
Version: \*(.*)\*.*/\1/p')"
+          current_version="$(git log -1 --format='%H')"
+
+          echo "Last Version: ${last_version}"
+          echo "Current Version: ${current_version}"
+
+          should_release=false
+          if [[ -z "${last_version}" ]]; then
+            echo "The first release was detected."
+            should_release=true
+          elif [[ "${last_version}" != "${current_version}" ]]; then
+            cmd="git diff --name-only ${last_version} ${current_version} | 
grep -E '^thirdparty/'"
+            echo "Execute: ${cmd}"
+            content="$(eval "${cmd}")" || true
+            if [[ -n "${content}" ]]; then
+              echo -e "Detect changes:\n${content}"
+              should_release=true
+            fi
+          fi
+
+          if [[ -z "${last_version}" ]]; then
+            echo -ne "Update Time: *$(date)*\nDoris Version: 
*${current_version}*" >release_note.md
+          else
+            gh release view automation | sed -n '/--/,$p' | awk '{ if (NR > 1) 
print $0 }' | sed "{
+              s/Update Time:.*/Update Time: *$(date)*/
+              s/Doris Version:.*/Doris Version: *${current_version}*/
+            }" >release_note.md
+          fi
+          gh release edit -F release_note.md automation
+
+          echo "should_release=${should_release}" >> $GITHUB_OUTPUT
+
+      - name: Download Source and Upload
+        if: steps.check_diff.outputs.should_release == 'true'
+        run: |
+          cd thirdparty
+          sed '/# unpacking thirdpart archives/,$d' download-thirdparty.sh | 
bash -
+
+          tar -zcvf doris-thirdparty-source.tgz src
+
+          gh release upload --clobber automation doris-thirdparty-source.tgz
+
+  build:
+    name: Build
+    needs: prerelease
+    if: needs.prerelease.outputs.should_release == 'true'
+    strategy:
+      matrix:
+        config:
+          - name: macOS
+            os: macos-12
+            packages: >-
+              'automake'
+              'autoconf'
+              'libtool'
+              'pkg-config'
+              'texinfo'
+              'coreutils'
+              'gnu-getopt'
+              'python'
+              'cmake'
+              'ninja'
+              'ccache'
+              'bison'
+              'byacc'
+              'gettext'
+              'wget'
+              'pcre'
+              'openjdk@11'
+              'maven'
+              'node'
+
+          - name: Linux
+            os: ubuntu-22.04
+            packages: >-
+              'build-essential'
+              'automake'
+              'autoconf'
+              'libtool-bin'
+              'pkg-config'
+              'cmake'
+              'ninja-build'
+              'ccache'
+              'python-is-python3'
+              'bison'
+              'byacc'
+              'flex'
+              'binutils-dev'
+              'libiberty-dev'
+              'curl'
+              'git'
+              'zip'
+              'unzip'
+              'autopoint'
+              'openjdk-11-jdk'
+              'openjdk-11-jdk-headless'
+              'maven'
+
+    runs-on: ${{ matrix.config.os }}
+    env:
+      GH_REPO: ${{ github.repository }}
+      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          repository: 'apache/doris'
+
+      - name: Download
+        run: |
+          cd thirdparty
+          gh release download automation
+          tar -zxvf doris-thirdparty-source.tgz
+
+      - name: Prepare for ${{ matrix.config.os }}
+        run: |
+          if [[ "${{ matrix.config.name }}" == 'macOS' ]]; then
+            brew install ${{ matrix.config.packages }}
+          else
+            export DEFAULT_DIR='/opt/doris'
+            export PATH="${DEFAULT_DIR}/ldb-toolchain/bin:${PATH}"
+
+            sudo apt update
+            sudo apt upgrade --yes
+            sudo DEBIAN_FRONTEND=noninteractive apt install --yes ${{ 
matrix.config.packages }}
+
+            mkdir -p "${DEFAULT_DIR}"
+            wget 
https://github.com/amosbird/ldb_toolchain_gen/releases/download/v0.12/ldb_toolchain_gen.sh
 \
+              -q -O /tmp/ldb_toolchain_gen.sh
+            bash /tmp/ldb_toolchain_gen.sh "${DEFAULT_DIR}/ldb-toolchain"
+          fi
+
+      - name: Build and Upload
+        run: |
+          if [[ "${{ matrix.config.name }}" == 'Linux' ]]; then
+            export DEFAULT_DIR='/opt/doris'
+            export PATH="${DEFAULT_DIR}/ldb-toolchain/bin:${PATH}"
+          fi
+
+          cd thirdparty
+          ./build-thirdparty.sh -j "$(nproc)"
+
+          kernel="$(uname -s | awk '{print tolower($0)}')"
+          arch="$(uname -m)"
+          rm -rf "doris-thirdparty-prebuilt-${kernel}-${arch}.tar.xz"
+          tar -cf - installed | xz -z -T0 - 
>"doris-thirdparty-prebuilt-${kernel}-${arch}.tar.xz"
+          gh release upload --clobber automation 
"doris-thirdparty-prebuilt-${kernel}-${arch}.tar.xz"
+
+  checksums:
+    name: Checksums
+    needs: [prerelease, build]
+    if: needs.prerelease.outputs.should_release == 'true'
+    runs-on: ubuntu-latest
+    env:
+      GH_REPO: ${{ github.repository }}
+      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+    permissions:
+      contents: write
+    steps:
+      - name: Update Checksums
+        run: |
+          gh release download automation
+
+          content="$(gh release view automation | sed -n '/Update 
Time:/,/Doris Version:/p')"
+          echo -ne "${content}\n\n## Checksums\n\`\`\`\n$(sha256sum 
*)\n\`\`\`" >release_note.md
+          gh release edit -F release_note.md automation


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to