Skip to content

Commit b805abc

Browse files
committed
Add artifact build pipeline
1 parent 9dc8c31 commit b805abc

File tree

6 files changed

+347
-19
lines changed

6 files changed

+347
-19
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# This workflow uses actions that are not certified by GitHub.
21+
# They are provided by a third-party and are governed by
22+
# separate terms of service, privacy policy, and support
23+
# documentation.
24+
25+
name: "Build Python Client Release Pypi Artifacts"
26+
27+
on:
28+
workflow_call:
29+
inputs:
30+
VERSION:
31+
required: true
32+
type: string
33+
34+
jobs:
35+
pypi-build-artifacts:
36+
name: Build artifacts for SVN on ${{ matrix.os }}
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
matrix:
40+
os: [ ubuntu-24.04, macos-14, macos-15] # current build script is not compatible with windows
41+
42+
steps:
43+
- uses: actions/checkout@v5
44+
with:
45+
fetch-depth: 1
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v6
49+
with:
50+
python-version: |
51+
3.10
52+
3.11
53+
3.12
54+
3.13
55+
- name: Set up JDK for openapi-generator-cli
56+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5
57+
with:
58+
distribution: 'temurin'
59+
java-version: '21'
60+
61+
- name: Set version with RC
62+
run:
63+
64+
- name: Set version with RC
65+
env:
66+
VERSION: ${{ inputs.VERSION }}
67+
run: make client-set-version VERSION="${{ env.VERSION }}"
68+
69+
- name: Build source distribution
70+
run: |
71+
make client-build FORMAT=sdist
72+
73+
- name: Build wheels
74+
uses: pypa/cibuildwheel@v3.1.4
75+
with:
76+
output-dir: wheelhouse
77+
package-dir: "./client/python"
78+
config-file: "{package}/pyproject.toml"
79+
env:
80+
# Ignore 32 bit architectures
81+
CIBW_ARCHS: "auto64"
82+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9,<3.14"
83+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # Disable wheel repair since there will be no binary in the wheel
84+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: ""
85+
CIBW_ENVIRONMENT: POLARIS_CLI_SKIP_CLIENT_GENERATION="true" # java is not available in linux containers during wheel build, skip client generation
86+
87+
- name: Add source distribution
88+
if: startsWith(matrix.os, 'ubuntu-24.04')
89+
run: ls -lah ./client/python/dist/* && cp ./client/python/dist/* wheelhouse/
90+
91+
92+
- uses: actions/upload-artifact@v4
93+
with:
94+
name: "python-client-pypi-release-candidate-${{ matrix.os }}"
95+
path: ./wheelhouse/*
96+
97+
pypi-merge-artifacts:
98+
runs-on: ubuntu-latest
99+
needs:
100+
- pypi-build-artifacts
101+
steps:
102+
- name: Merge Artifacts
103+
uses: actions/upload-artifact/merge@v4
104+
with:
105+
name: "python-client-pypi-release-candidate-${{ inputs.VERSION }}"
106+
pattern: python-client-pypi-release-candidate*
107+
delete-merged: true
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# This workflow uses actions that are not certified by GitHub.
21+
# They are provided by a third-party and are governed by
22+
# separate terms of service, privacy policy, and support
23+
# documentation.
24+
25+
name: "Build Python Client Release SVN Artifacts"
26+
27+
on:
28+
workflow_call:
29+
inputs:
30+
VERSION:
31+
required: true
32+
type: string
33+
34+
jobs:
35+
svn-build-artifacts:
36+
name: Build artifacts for SVN on ${{ matrix.os }}
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
matrix:
40+
os: [ ubuntu-24.04, macos-14, macos-15] # current build script is not compatible with windows
41+
42+
steps:
43+
- uses: actions/checkout@v5
44+
with:
45+
fetch-depth: 1
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v6
49+
with:
50+
python-version: |
51+
3.10
52+
3.11
53+
3.12
54+
3.13
55+
- name: Set up JDK for openapi-generator-cli
56+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5
57+
with:
58+
distribution: 'temurin'
59+
java-version: '21'
60+
61+
- name: Build source distribution
62+
run: |
63+
make client-build FORMAT=sdist
64+
65+
- name: Build wheels
66+
uses: pypa/cibuildwheel@v3.1.4
67+
with:
68+
output-dir: wheelhouse
69+
package-dir: "./client/python"
70+
config-file: "{package}/pyproject.toml"
71+
env:
72+
# Ignore 32 bit architectures
73+
CIBW_ARCHS: "auto64"
74+
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9,<3.14"
75+
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" # Disable wheel repair since there will be no binary in the wheel
76+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: ""
77+
CIBW_ENVIRONMENT: POLARIS_CLI_SKIP_CLIENT_GENERATION="true" # java is not available in linux containers during wheel build, skip client generation
78+
79+
- name: Add source distribution
80+
if: startsWith(matrix.os, 'ubuntu-24.04')
81+
run: ls -lah ./client/python/dist/* && cp ./client/python/dist/* wheelhouse/
82+
83+
84+
- uses: actions/upload-artifact@v4
85+
with:
86+
name: "python-client-svn-release-candidate-${{ matrix.os }}"
87+
path: ./wheelhouse/*
88+
89+
svn-merge-artifacts:
90+
runs-on: ubuntu-latest
91+
needs:
92+
- svn-build-artifacts
93+
steps:
94+
- name: Merge Artifacts
95+
uses: actions/upload-artifact/merge@v4
96+
with:
97+
name: "python-client-svn-release-candidate-${{ inputs.VERSION }}"
98+
pattern: python-client-svn-release-candidate*
99+
delete-merged: true
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# This workflow uses actions that are not certified by GitHub.
21+
# They are provided by a third-party and are governed by
22+
# separate terms of service, privacy policy, and support
23+
# documentation.
24+
25+
name: "Python Client Build Release Candidate"
26+
27+
on:
28+
workflow_dispatch:
29+
inputs:
30+
version:
31+
description: 'Version (e.g. 1.1.0)'
32+
type: string
33+
required: true
34+
rc:
35+
description: 'Release Candidate (RC) (e.g. 1)'
36+
type: number
37+
required: true
38+
pull_request:
39+
paths:
40+
- '.github/workflows/python-release-build.yml'
41+
- '.github/workflows/python-client-release-svn-artifact.yml'
42+
- 'client/python/**'
43+
44+
jobs:
45+
validate-inputs:
46+
runs-on: ubuntu-latest
47+
outputs:
48+
VERSION: ${{ steps.validate-inputs.outputs.VERSION }}
49+
RC: ${{ steps.validate-inputs.outputs.RC }}
50+
steps:
51+
- name: Validate Version and RC
52+
id: validate-inputs
53+
run: |
54+
# Use test values for pull_request trigger, actual inputs for workflow_dispatch
55+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
56+
echo "Workflow triggered by pull_request - using test values"
57+
VERSION="1.2.0"
58+
RC="1"
59+
else
60+
echo "Workflow triggered manually via workflow_dispatch."
61+
VERSION="${{ github.event.inputs.version }}"
62+
RC="${{ github.event.inputs.rc }}"
63+
fi
64+
65+
# Validate version (e.g., 1.0.0)
66+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
67+
echo "Error: version ($VERSION) must be in the format: <number>.<number>.<number>"
68+
exit 1
69+
fi
70+
# Validate rc (e.g., 1)
71+
if [[ ! "$RC" =~ ^[0-9]+$ ]]; then
72+
echo "Error: rc ($RC) must be in the format: <number>"
73+
exit 1
74+
fi
75+
76+
# Export variables for future steps
77+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
78+
echo "RC=$RC" >> $GITHUB_OUTPUT
79+
- name: Display Extracted Version and RC
80+
run: |
81+
echo "Using Version: ${{ steps.validate-inputs.outputs.VERSION }}"
82+
echo "Using RC: ${{ steps.validate-inputs.outputs.RC }}"
83+
validate-client-version:
84+
runs-on: ubuntu-latest
85+
needs:
86+
- validate-inputs
87+
steps:
88+
- uses: actions/checkout@v5
89+
with:
90+
fetch-depth: 1
91+
92+
- uses: actions/setup-python@v6
93+
with:
94+
python-version: 3.12
95+
96+
- name: Setup Environment
97+
run: |
98+
export POETRY_VERSION=$(cat client/python/pyproject.toml | grep requires-poetry | sed 's/requires-poetry *= *"\(.*\)"/\1/')
99+
python3 -m pip install poetry$POETRY_VERSION
100+
- name: Validate Current Client Version
101+
working-directory: ./client/python
102+
env:
103+
VERSION: ${{ needs.validate-inputs.outputs.VERSION }}
104+
run: |
105+
current_polaris_client_version=$(poetry version --short)
106+
echo "Detected Poetry version: $current_polaris_client_version"
107+
108+
# Compare the input version with the Poetry version
109+
if [[ "$VERSION" != "$current_polaris_client_version" ]]; then
110+
echo "Error: Input version ($VERSION) does not match the Poetry version ($current_polaris_client_version)"
111+
exit 1
112+
fi
113+
114+
svn-build-artifacts:
115+
needs:
116+
- validate-inputs
117+
- validate-client-version
118+
uses: ./.github/workflows/python-client-release-svn-artifact.yml
119+
with:
120+
VERSION: ${{ needs.validate-inputs.outputs.VERSION }}rc${{ needs.validate-inputs.outputs.RC }}
121+
122+
pypi-build-artifacts:
123+
needs:
124+
- validate-inputs
125+
- validate-client-version
126+
uses: ./.github/workflows/python-client-release-pypi-artifact.yml
127+
with:
128+
VERSION: ${{ needs.validate-inputs.outputs.VERSION }}rc${{ needs.validate-inputs.outputs.RC }}

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ client-lint: client-setup-env ## Run linting checks for Polaris client
131131
@$(ACTIVATE_AND_CD) && poetry run pre-commit run --files integration_tests/* python/cli/*
132132
@echo "--- Client linting checks complete ---"
133133

134+
.PHONY: client-set-version
135+
client-set-version: client-setup-env ## Set Python client version using poetry. Usage: make client-set-version VERSION=<version>
136+
@echo "--- Setting client version ---"
137+
@if [ -z "$(VERSION)" ]; then \
138+
echo "Error: VERSION is required. Usage: make client-set-version VERSION=<version>" >&2; \
139+
exit 1; \
140+
fi
141+
@$(ACTIVATE_AND_CD) && poetry version "$(VERSION)"
142+
@echo "--- Client version set to $(VERSION) ---"
143+
134144
.PHONY: client-regenerate
135145
client-regenerate: client-setup-env ## Regenerate the client code
136146
@echo "--- Regenerating client code ---"
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +0,0 @@
1-
#
2-
# Licensed to the Apache Software Foundation (ASF) under one
3-
# or more contributor license agreements. See the NOTICE file
4-
# distributed with this work for additional information
5-
# regarding copyright ownership. The ASF licenses this file
6-
# to you under the Apache License, Version 2.0 (the
7-
# "License"); you may not use this file except in compliance
8-
# with the License. You may obtain a copy of the License at
9-
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
12-
# Unless required by applicable law or agreed to in writing,
13-
# software distributed under the License is distributed on an
14-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
# KIND, either express or implied. See the License for the
16-
# specific language governing permissions and limitations
17-
# under the License.
18-
#
19-

client/python/generate_clients.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ def main():
324324
else:
325325
logging.basicConfig(level=logging.INFO, format="%(message)s")
326326

327+
if os.environ.get("POLARIS_CLI_SKIP_CLIENT_GENERATION", "false").lower() == "true":
328+
logger.info("POLARIS_CLI_SKIP_CLIENT_GENERATION is set to true, skipping client generation.")
329+
return
327330
build()
328331

329332

0 commit comments

Comments
 (0)