-
Notifications
You must be signed in to change notification settings - Fork 340
Workflow to build python CLI artifacts (sdist + wheels) #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
d30d9fa
e67bfcb
3c53fbf
2b07c3e
f2331e0
6c5b7f3
2578b89
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,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 | ||
|
Comment on lines
+44
to
+46
Member
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. Is there anything that's performance critical in the Python package?
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. Yeah, ideally we only need a universal wheel since everything is pure python. However, since we need to leverage a custom build script to do open api client generation, poetry thinks it needs to generate platform-specific wheels. This is a known limitation and seems we have no native way to override this behavior now. Should the situation changed in the future, we should definitely switch to universal wheel if possible. |
||
| 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/ | ||
|
|
||
HonahX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - 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 }}" | ||
|
Comment on lines
+102
to
+103
Member
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. What's the reason for this special case?
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. It could make the output zip file name indicate that a custom version has been provided hence the built sdist and wheels will have its package version changed. Just for convenience. |
||
| 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this WF is just for nightly builds?
I'm confused about the need for a "version" input and that the WF is triggered by PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
versionhere is optional and used to set the package version hereIn the nightly build, we will need to determine a convention of the package version for nightly build, such as including commit hash/date to the package version, so we could have a better reference in test.pypi.org. But IMHO the details of the version we want to set to the package could be determined in the actual nightly build publication step. This workflow should focus on building all the wheels required, by default leave the package version unchanged and make it an option for any upstream caller to set the version as needed. WDYT?