| # |
| # 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 IoTDB Tools Thrift Artifacts |
| |
| on: |
| workflow_dispatch: |
| inputs: |
| git_ref: |
| description: Optional branch, tag, or commit SHA to build |
| required: false |
| type: string |
| pull_request: |
| paths: |
| - .github/workflows/iotdb-tools-thrift-artifacts.yml |
| - iotdb-tools-thrift/** |
| |
| permissions: |
| contents: read |
| |
| concurrency: |
| group: iotdb-tools-thrift-artifacts-${{ github.ref }} |
| cancel-in-progress: false |
| |
| jobs: |
| build: |
| name: Build ${{ matrix.classifier }} |
| runs-on: ${{ matrix.runner }} |
| strategy: |
| fail-fast: false |
| matrix: |
| include: |
| - classifier: linux-x86_64 |
| runner: ubuntu-24.04 |
| platform: linux |
| maven: ./mvnw |
| - classifier: linux-aarch64 |
| runner: ubuntu-24.04-arm |
| platform: linux |
| maven: ./mvnw |
| - classifier: mac-x86_64 |
| runner: macos-15-intel |
| platform: macos |
| maven: ./mvnw |
| - classifier: mac-aarch64 |
| runner: macos-15 |
| platform: macos |
| maven: ./mvnw |
| - classifier: windows-x86_64 |
| runner: windows-2022 |
| platform: windows |
| maven: .\mvnw.cmd |
| - classifier: windows-aarch64 |
| runner: windows-11-arm |
| platform: windows |
| maven: .\mvnw.cmd |
| |
| steps: |
| - name: Check out source |
| uses: actions/checkout@v7 |
| with: |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.git_ref || github.ref }} |
| |
| - name: Set up Java |
| uses: actions/setup-java@v5 |
| with: |
| distribution: temurin |
| java-version: 21 |
| cache: maven |
| |
| - name: Install Linux build prerequisites |
| if: matrix.platform == 'linux' |
| run: | |
| sudo apt-get update |
| sudo apt-get install -y flex bison g++ make |
| |
| - name: Install macOS build prerequisites |
| if: matrix.platform == 'macos' |
| run: brew install bison |
| |
| - name: Install Windows build prerequisites |
| if: matrix.platform == 'windows' |
| shell: pwsh |
| run: choco install winflexbison3 -y --no-progress |
| |
| - name: Verify active Maven classifier |
| working-directory: iotdb-tools-thrift |
| shell: pwsh |
| run: | |
| $expected = "${{ matrix.classifier }}" |
| $actual = & "${{ matrix.maven }}" -q help:evaluate "-Dexpression=os.classifier" "-DforceStdout" |
| if ($LASTEXITCODE -ne 0) { |
| exit $LASTEXITCODE |
| } |
| $actual = ($actual | Select-Object -Last 1).Trim() |
| Write-Host "Expected classifier: $expected" |
| Write-Host "Maven classifier: $actual" |
| if ($actual -ne $expected) { |
| throw "Maven activated classifier '$actual', expected '$expected'" |
| } |
| |
| - name: Build artifact |
| working-directory: iotdb-tools-thrift |
| shell: pwsh |
| run: | |
| & "${{ matrix.maven }}" clean package -DskipTests |
| if ($LASTEXITCODE -ne 0) { |
| exit $LASTEXITCODE |
| } |
| |
| - name: Verify archive contents |
| working-directory: iotdb-tools-thrift |
| shell: pwsh |
| run: | |
| $classifier = "${{ matrix.classifier }}" |
| $zip = Get-ChildItem -Path target -Filter "*-$classifier.zip" | Select-Object -First 1 |
| if (-not $zip) { |
| throw "No zip file found for classifier $classifier" |
| } |
| |
| Add-Type -AssemblyName System.IO.Compression.FileSystem |
| $archive = [System.IO.Compression.ZipFile]::OpenRead($zip.FullName) |
| try { |
| $files = $archive.Entries | Where-Object { $_.Name } | ForEach-Object { $_.FullName } |
| } finally { |
| $archive.Dispose() |
| } |
| |
| $expectedBinary = if ($classifier.StartsWith("windows")) { "bin/Release/thrift.exe" } else { "bin/thrift" } |
| Write-Host "Archive: $($zip.Name)" |
| $files | ForEach-Object { Write-Host " - $_" } |
| |
| if ($files.Count -ne 1) { |
| throw "Expected exactly one file in the archive, found $($files.Count)" |
| } |
| if ($files -notcontains $expectedBinary) { |
| throw "Expected archive to contain $expectedBinary" |
| } |
| |
| $extractDir = Join-Path $env:RUNNER_TEMP "thrift-$classifier" |
| Remove-Item -Recurse -Force $extractDir -ErrorAction SilentlyContinue |
| Expand-Archive -Path $zip.FullName -DestinationPath $extractDir |
| $binary = Join-Path $extractDir $expectedBinary |
| if (-not (Test-Path $binary)) { |
| throw "Expected binary not found after extraction: $expectedBinary" |
| } |
| if (-not $classifier.StartsWith("windows")) { |
| chmod +x $binary |
| } |
| |
| $version = & $binary --version |
| if ($LASTEXITCODE -ne 0) { |
| exit $LASTEXITCODE |
| } |
| $version = ($version | Select-Object -Last 1).Trim() |
| Write-Host "Thrift version output: $version" |
| if ($version -ne "Thrift version 0.23.0") { |
| throw "Unexpected thrift version output: $version" |
| } |
| |
| if ($classifier.StartsWith("linux")) { |
| $fileInfo = & file $binary |
| Write-Host "file output: $fileInfo" |
| if ($fileInfo -notmatch "statically linked") { |
| throw "Expected Linux thrift binary to be statically linked" |
| } |
| } |
| |
| - name: Upload platform artifact |
| uses: actions/upload-artifact@v7 |
| with: |
| name: iotdb-tools-thrift-${{ matrix.classifier }} |
| path: iotdb-tools-thrift/target/*-${{ matrix.classifier }}.zip |
| if-no-files-found: error |
| compression-level: 0 |
| retention-days: 14 |
| |
| bundle: |
| name: Bundle all platform artifacts |
| runs-on: ubuntu-24.04 |
| needs: build |
| steps: |
| - name: Download platform artifacts |
| uses: actions/download-artifact@v8 |
| with: |
| path: dist |
| pattern: iotdb-tools-thrift-* |
| merge-multiple: true |
| |
| - name: Verify bundled artifacts |
| shell: bash |
| run: | |
| set -euo pipefail |
| ls -lah dist |
| test "$(find dist -maxdepth 1 -name '*.zip' | wc -l)" -eq 6 |
| for classifier in linux-x86_64 linux-aarch64 mac-x86_64 mac-aarch64 windows-x86_64 windows-aarch64; do |
| test "$(find dist -maxdepth 1 -name "*-${classifier}.zip" | wc -l)" -eq 1 |
| done |
| |
| - name: Upload bundled artifact |
| uses: actions/upload-artifact@v7 |
| with: |
| name: iotdb-tools-thrift-all-platforms |
| path: dist/*.zip |
| if-no-files-found: error |
| compression-level: 0 |
| retention-days: 14 |