|
| 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 }} |
0 commit comments