diff --git a/.github/workflows/python-client-build-artifacts.yml b/.github/workflows/python-client-build-artifacts.yml new file mode 100644 index 0000000000..19db296c5b --- /dev/null +++ b/.github/workflows/python-client-build-artifacts.yml @@ -0,0 +1,116 @@ +# +# 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: "Python Client Build Artifacts" + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to set (optional, e.g. 1.1.0 or 1.1.0rc1 or dev-20251202-abc1234)' + type: string + required: false + workflow_call: + inputs: + version: + description: 'Version to set (optional)' + type: string + required: false + pull_request: + paths: + - '.github/workflows/python-client-build-artifacts.yml' + - 'client/python/**' + +jobs: + build-artifacts: + name: Build artifacts on ${{ matrix.os }} with Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-24.04, macos-14, macos-15] # current build script is not compatible with windows + python-version: [ "3.10", "3.11", "3.12", "3.13" ] + + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 1 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Set up JDK for openapi-generator-cli + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 + with: + distribution: 'temurin' + java-version: '21' + + - name: Set version (if provided) + if: inputs.version != '' + env: + VERSION: ${{ inputs.version }} + run: make client-set-version VERSION="${{ env.VERSION }}" + + - name: Build source distribution + if: matrix.python-version == '3.13' && startsWith(matrix.os, 'ubuntu-24.04') + run: | + make client-build FORMAT=sdist + + - name: Build wheel + run: | + make client-build FORMAT=wheel + + - name: Prepare artifacts directory + run: | + mkdir -p wheelhouse + cp ./client/python/dist/*.whl wheelhouse/ + + - name: Add source distribution + if: matrix.python-version == '3.13' && startsWith(matrix.os, 'ubuntu-24.04') + run: cp ./client/python/dist/*.tar.gz wheelhouse/ + + - uses: actions/upload-artifact@v4 + with: + name: "python-client-artifacts-${{ matrix.os }}-py${{ matrix.python-version }}" + path: ./wheelhouse/* + + merge-artifacts: + runs-on: ubuntu-latest + needs: + - build-artifacts + steps: + - name: Generate artifact name + id: artifact-name + run: | + if [ -n "${{ inputs.version }}" ]; then + ARTIFACT_NAME="python-client-artifacts-${{ inputs.version }}" + else + ARTIFACT_NAME="python-client-artifacts-${{ github.run_id }}" + fi + echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_OUTPUT + echo "Using artifact name: $ARTIFACT_NAME" + + - name: Merge Artifacts + uses: actions/upload-artifact/merge@v4 + with: + name: ${{ steps.artifact-name.outputs.ARTIFACT_NAME }} + pattern: python-client-artifacts-* + delete-merged: true + diff --git a/Makefile b/Makefile index 20908284fd..a56dec54a1 100644 --- a/Makefile +++ b/Makefile @@ -131,6 +131,16 @@ client-lint: client-setup-env ## Run linting checks for Polaris client @$(ACTIVATE_AND_CD) && poetry run pre-commit run --files integration_tests/* python/cli/* @echo "--- Client linting checks complete ---" +.PHONY: client-set-version +client-set-version: client-setup-env ## Set Python client version using poetry. Usage: make client-set-version VERSION= + @echo "--- Setting client version ---" + @if [ -z "$(VERSION)" ]; then \ + echo "Error: VERSION is required. Usage: make client-set-version VERSION=" >&2; \ + exit 1; \ + fi + @$(ACTIVATE_AND_CD) && poetry version "$(VERSION)" + @echo "--- Client version set to $(VERSION) ---" + .PHONY: client-regenerate client-regenerate: client-setup-env ## Regenerate the client code @echo "--- Regenerating client code ---"