-
Notifications
You must be signed in to change notification settings - Fork 332
Workflows to build python CLI release and pypi artifacts #3036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # | ||
| # 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 Python Client Release PyPI Artifacts" | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| VERSION: | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| pypi-build-artifacts: | ||
| name: Build artifacts for SVN on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ ubuntu-24.04, macos-14, macos-15] # current build script is not compatible with windows | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: | | ||
| 3.10 | ||
| 3.11 | ||
| 3.12 | ||
| 3.13 | ||
| - name: Set up JDK for openapi-generator-cli | ||
| uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '21' | ||
|
|
||
| - name: Set version with RC | ||
| env: | ||
| VERSION: ${{ inputs.VERSION }} | ||
| run: make client-set-version VERSION="${{ env.VERSION }}" | ||
|
|
||
| - name: Build source distribution | ||
| run: | | ||
| make client-build FORMAT=sdist | ||
|
|
||
| - name: Build wheels | ||
| uses: pypa/[email protected] | ||
| with: | ||
| output-dir: wheelhouse | ||
| package-dir: "./client/python" | ||
| config-file: "{package}/pyproject.toml" | ||
| env: | ||
| # Ignore 32 bit architectures | ||
| CIBW_ARCHS: "auto64" | ||
| CIBW_PROJECT_REQUIRES_PYTHON: ">=3.10,<3.14" | ||
| CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # Disable wheel repair since there will be no binary in the wheel | ||
| CIBW_REPAIR_WHEEL_COMMAND_LINUX: "" | ||
| CIBW_ENVIRONMENT: POLARIS_CLI_SKIP_CLIENT_GENERATION="true" # java is not available in linux containers during wheel build, skip client generation | ||
|
|
||
| - name: Add source distribution | ||
| if: startsWith(matrix.os, 'ubuntu-24.04') | ||
| run: ls -lah ./client/python/dist/* && cp ./client/python/dist/* wheelhouse/ | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: "python-client-pypi-release-candidate-${{ matrix.os }}" | ||
| path: ./wheelhouse/* | ||
|
|
||
| pypi-merge-artifacts: | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| - pypi-build-artifacts | ||
| steps: | ||
| - name: Merge Artifacts | ||
| uses: actions/upload-artifact/merge@v4 | ||
| with: | ||
| name: "python-client-pypi-release-candidate-${{ inputs.VERSION }}" | ||
| pattern: python-client-pypi-release-candidate* | ||
| delete-merged: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # | ||
| # 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 Python Client Release SVN Artifacts" | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| VERSION: | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| svn-build-artifacts: | ||
| name: Build artifacts for SVN on ${{ matrix.os }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ ubuntu-24.04, macos-14, macos-15] # current build script is not compatible with windows | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: | | ||
| 3.10 | ||
| 3.11 | ||
| 3.12 | ||
| 3.13 | ||
| - name: Set up JDK for openapi-generator-cli | ||
| uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '21' | ||
|
|
||
| - name: Build source distribution | ||
| run: | | ||
| make client-build FORMAT=sdist | ||
|
|
||
| - name: Build wheels | ||
| uses: pypa/[email protected] | ||
| with: | ||
| output-dir: wheelhouse | ||
| package-dir: "./client/python" | ||
| config-file: "{package}/pyproject.toml" | ||
| env: | ||
| # Ignore 32 bit architectures | ||
| CIBW_ARCHS: "auto64" | ||
| CIBW_PROJECT_REQUIRES_PYTHON: ">=3.10,<3.14" | ||
| CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # Disable wheel repair since there will be no binary in the wheel | ||
| CIBW_REPAIR_WHEEL_COMMAND_LINUX: "" | ||
| CIBW_ENVIRONMENT: POLARIS_CLI_SKIP_CLIENT_GENERATION="true" # java is not available in linux containers during wheel build, skip client generation | ||
|
|
||
| - name: Add source distribution | ||
| if: startsWith(matrix.os, 'ubuntu-24.04') | ||
| run: ls -lah ./client/python/dist/* && cp ./client/python/dist/* wheelhouse/ | ||
|
|
||
HonahX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: "python-client-svn-release-candidate-${{ matrix.os }}" | ||
| path: ./wheelhouse/* | ||
|
|
||
| svn-merge-artifacts: | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| - svn-build-artifacts | ||
| steps: | ||
| - name: Merge Artifacts | ||
| uses: actions/upload-artifact/merge@v4 | ||
| with: | ||
| name: "python-client-svn-release-candidate-${{ inputs.VERSION }}" | ||
| pattern: python-client-svn-release-candidate* | ||
| delete-merged: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # | ||
| # 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 Release Candidate" | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version (e.g. 1.1.0)' | ||
| type: string | ||
| required: true | ||
| rc: | ||
| description: 'Release Candidate (RC) (e.g. 1)' | ||
| type: number | ||
| required: true | ||
| pull_request: | ||
| paths: | ||
| - '.github/workflows/python-release-build.yml' | ||
| - '.github/workflows/python-client-release-svn-artifact.yml' | ||
| - 'client/python/**' | ||
|
|
||
| jobs: | ||
| validate-inputs: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| VERSION: ${{ steps.validate-inputs.outputs.VERSION }} | ||
| RC: ${{ steps.validate-inputs.outputs.RC }} | ||
| steps: | ||
| - name: Validate Version and RC | ||
| id: validate-inputs | ||
| run: | | ||
| # Use test values for pull_request trigger, actual inputs for workflow_dispatch | ||
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
| echo "Workflow triggered by pull_request - using test values" | ||
| VERSION="1.2.0" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: Not sure if we should use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello 👋 Just want to highlight that in this dev@ thread was discussed legal aspects and versioning. I think it's better to sync with JB and other engineers who has expertise.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @MonkeyCanCode @binarycat0 This aims to be an example version when the workflow is triggered by pull request to verify if CLI changes break the wheel build When it comes to real release, the release manager will need to manually enter the version and rc number to build the release artifacts. And the workflow will verify if the version is consistent with the one in the package metadata For example (pyiceberg) And of course, in the future it could be integrated into release automation pipeline |
||
| RC="1" | ||
| else | ||
| echo "Workflow triggered manually via workflow_dispatch." | ||
| VERSION="${{ github.event.inputs.version }}" | ||
| RC="${{ github.event.inputs.rc }}" | ||
| fi | ||
|
|
||
| # Validate version (e.g., 1.0.0) | ||
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Error: version ($VERSION) must be in the format: <number>.<number>.<number>" | ||
| exit 1 | ||
| fi | ||
| # Validate rc (e.g., 1) | ||
| if [[ ! "$RC" =~ ^[0-9]+$ ]]; then | ||
| echo "Error: rc ($RC) must be in the format: <number>" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Export variables for future steps | ||
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | ||
| echo "RC=$RC" >> $GITHUB_OUTPUT | ||
| - name: Display Extracted Version and RC | ||
| run: | | ||
| echo "Using Version: ${{ steps.validate-inputs.outputs.VERSION }}" | ||
| echo "Using RC: ${{ steps.validate-inputs.outputs.RC }}" | ||
| validate-client-version: | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| - validate-inputs | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: 3.12 | ||
|
|
||
| - name: Setup Environment | ||
| run: | | ||
| export POETRY_VERSION=$(cat client/python/pyproject.toml | grep requires-poetry | sed 's/requires-poetry *= *"\(.*\)"/\1/') | ||
| python3 -m pip install poetry$POETRY_VERSION | ||
| - name: Validate Current Client Version | ||
| working-directory: ./client/python | ||
| env: | ||
| VERSION: ${{ needs.validate-inputs.outputs.VERSION }} | ||
| run: | | ||
| current_polaris_client_version=$(poetry version --short) | ||
| echo "Detected Poetry version: $current_polaris_client_version" | ||
|
|
||
| # Compare the input version with the Poetry version | ||
| if [[ "$VERSION" != "$current_polaris_client_version" && "${github_event_name}" != "pull_request" ]]; then | ||
| echo "Error: Input version ($VERSION) does not match the Poetry version ($current_polaris_client_version)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| svn-build-artifacts: | ||
| needs: | ||
| - validate-inputs | ||
| - validate-client-version | ||
| uses: ./.github/workflows/python-client-release-svn-artifact.yml | ||
| with: | ||
| VERSION: ${{ needs.validate-inputs.outputs.VERSION }}rc${{ needs.validate-inputs.outputs.RC }} | ||
|
|
||
| pypi-build-artifacts: | ||
| needs: | ||
| - validate-inputs | ||
| - validate-client-version | ||
| uses: ./.github/workflows/python-client-release-pypi-artifact.yml | ||
| with: | ||
| VERSION: ${{ needs.validate-inputs.outputs.VERSION }}rc${{ needs.validate-inputs.outputs.RC }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,6 +324,9 @@ def main(): | |
| else: | ||
| logging.basicConfig(level=logging.INFO, format="%(message)s") | ||
|
|
||
| if os.environ.get("POLARIS_CLI_SKIP_CLIENT_GENERATION", "false").lower() == "true": | ||
| logger.info("POLARIS_CLI_SKIP_CLIENT_GENERATION is set to true, skipping client generation.") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cibuildwheel environment does not have java, so we add this to skip the generation there |
||
| return | ||
| build() | ||
|
|
||
|
|
||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.