|
17 | 17 | # under the License. |
18 | 18 | # |
19 | 19 |
|
20 | | -name: "Python Release" |
| 20 | +name: "Python Build Release Candidate" |
21 | 21 |
|
22 | 22 | on: |
| 23 | + push: |
| 24 | + tags: |
| 25 | + # Trigger this workflow when tag follows the versioning format: pyiceberg-<major>.<minor>.<patch>rc<release_candidate> |
| 26 | + # Example valid tags: pyiceberg-0.8.0rc2, pyiceberg-1.0.0rc1 |
| 27 | + - 'pyiceberg-[0-9]+.[0-9]+.[0-9]+rc[0-9]+' |
23 | 28 | workflow_dispatch: |
24 | 29 | inputs: |
25 | 30 | version: |
26 | | - description: 'Version' |
| 31 | + description: 'Version (e.g., 0.8.0)' |
27 | 32 | type: string |
28 | | - default: 'main' |
29 | | - |
| 33 | + required: true |
| 34 | + rc: |
| 35 | + description: 'Release Candidate (RC) (e.g., 1)' |
| 36 | + type: number |
| 37 | + required: true |
30 | 38 |
|
31 | 39 | jobs: |
32 | | - build_wheels: |
33 | | - name: Build wheels on ${{ matrix.os }} |
34 | | - runs-on: ${{ matrix.os }} |
35 | | - strategy: |
36 | | - matrix: |
37 | | - os: [ ubuntu-22.04, windows-2022, macos-13, macos-14, macos-15 ] |
| 40 | + validate-inputs: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + outputs: |
| 43 | + VERSION: ${{ steps.validate-inputs.outputs.VERSION }} # e.g. 0.8.0 |
| 44 | + RC: ${{ steps.validate-inputs.outputs.RC }} # e.g. 1 |
| 45 | + steps: |
| 46 | + - name: Validate and Extract Version and RC |
| 47 | + id: validate-inputs |
| 48 | + run: | |
| 49 | + if [ "$GITHUB_EVENT_NAME" = "push" ]; then |
| 50 | + echo "Workflow triggered by tag push." |
| 51 | + TAG=${GITHUB_REF#refs/tags/} # Extract the tag name |
| 52 | + VERSION_AND_RC=${TAG#pyiceberg-} # Remove the 'pyiceberg-' prefix |
| 53 | + VERSION=${VERSION_AND_RC%rc*} # Extract VERSION by removing everything after 'rc' |
| 54 | + RC=${VERSION_AND_RC#*rc} # Extract RC by keeping everything after 'rc' |
| 55 | +
|
| 56 | + if [[ -z "$VERSION" || -z "$RC" ]]; then |
| 57 | + echo "Error: Unable to parse VERSION or RC from tag ($TAG). Ensure the tag format is correct." |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | + else |
| 61 | + echo "Workflow triggered manually via workflow_dispatch." |
| 62 | + VERSION="${{ github.event.inputs.version }}" |
| 63 | + RC="${{ github.event.inputs.rc }}" |
| 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 |
38 | 70 |
|
| 71 | + # Validate rc (e.g., 1) |
| 72 | + if [[ ! "$RC" =~ ^[0-9]+$ ]]; then |
| 73 | + echo "Error: rc ($RC) must be in the format: <number>" |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | + fi |
| 77 | +
|
| 78 | + # Export variables for future steps |
| 79 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 80 | + echo "RC=$RC" >> $GITHUB_OUTPUT |
| 81 | +
|
| 82 | + - name: Display Extracted Version and RC |
| 83 | + run: | |
| 84 | + echo "Using Version: ${{ steps.validate-inputs.outputs.VERSION }}" |
| 85 | + echo "Using RC: ${{ steps.validate-inputs.outputs.RC }}" |
| 86 | +
|
| 87 | + validate-library-version: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + needs: |
| 90 | + - validate-inputs |
39 | 91 | steps: |
40 | 92 | - uses: actions/checkout@v4 |
41 | 93 | with: |
42 | | - fetch-depth: 0 |
| 94 | + fetch-depth: 1 |
43 | 95 |
|
44 | 96 | - uses: actions/setup-python@v5 |
45 | 97 | with: |
46 | | - python-version: | |
47 | | - 3.9 |
48 | | - 3.10 |
49 | | - 3.11 |
50 | | - 3.12 |
| 98 | + python-version: 3.12 |
51 | 99 |
|
52 | | - - name: Install poetry |
53 | | - run: pip install poetry |
| 100 | + - name: Install Poetry |
| 101 | + run: make install-poetry |
54 | 102 |
|
55 | | - - name: Set version |
56 | | - run: python -m poetry version "${{ inputs.version }}" |
57 | | - if: "${{ github.event.inputs.version != 'main' }}" |
58 | | - |
59 | | - # Publish the source distribution with the version that's in |
60 | | - # the repository, otherwise the tests will fail |
61 | | - - name: Compile source distribution |
62 | | - run: python3 -m poetry build --format=sdist |
63 | | - if: startsWith(matrix.os, 'ubuntu') |
64 | | - |
65 | | - - name: Build wheels |
66 | | - uses: pypa/cibuildwheel@v2.22.0 |
67 | | - with: |
68 | | - output-dir: wheelhouse |
69 | | - config-file: "pyproject.toml" |
| 103 | + - name: Validate current pyiceberg version |
70 | 104 | env: |
71 | | - # Ignore 32 bit architectures |
72 | | - CIBW_ARCHS: "auto64" |
73 | | - CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9,<3.13" |
74 | | - CIBW_TEST_REQUIRES: "pytest==7.4.2 moto==5.0.1" |
75 | | - CIBW_TEST_EXTRAS: "s3fs,glue" |
76 | | - CIBW_TEST_COMMAND: "pytest {project}/tests/avro/test_decoder.py" |
77 | | - # There is an upstream issue with installing on MacOSX |
78 | | - # https://github.com/pypa/cibuildwheel/issues/1603 |
79 | | - # Ignore tests for pypy since not all dependencies are compiled for it |
80 | | - # and would require a local rust build chain |
81 | | - CIBW_TEST_SKIP: "pp* *macosx*" |
| 105 | + VERSION: ${{ needs.validate-inputs.outputs.VERSION }} |
| 106 | + run: | |
| 107 | + # Extract the current version from Poetry |
| 108 | + current_pyiceberg_version=$(poetry version --short) |
| 109 | + echo "Detected Poetry version: $current_pyiceberg_version" |
82 | 110 |
|
83 | | - - name: Add source distribution |
84 | | - if: startsWith(matrix.os, 'ubuntu') |
85 | | - run: ls -lah dist/* && cp dist/* wheelhouse/ |
| 111 | + # Compare the input version with the Poetry version |
| 112 | + if [[ "$VERSION" != "$current_pyiceberg_version" ]]; then |
| 113 | + echo "Error: Input version ($VERSION) does not match the Poetry version ($current_pyiceberg_version)" |
| 114 | + exit 1 |
| 115 | + fi |
86 | 116 |
|
87 | | - - uses: actions/upload-artifact@v4 |
88 | | - with: |
89 | | - name: "release-${{ matrix.os }}" |
90 | | - path: ./wheelhouse/* |
91 | | - merge: |
92 | | - runs-on: ubuntu-latest |
93 | | - needs: build_wheels |
94 | | - steps: |
95 | | - - name: Merge Artifacts |
96 | | - uses: actions/upload-artifact/merge@v4 |
97 | | - with: |
98 | | - name: "release-${{ github.event.inputs.version }}" |
99 | | - pattern: release-* |
100 | | - delete-merged: true |
| 117 | + # SVN |
| 118 | + svn-build-artifacts: |
| 119 | + needs: |
| 120 | + - validate-inputs |
| 121 | + - validate-library-version |
| 122 | + uses: ./.github/workflows/svn-build-artifacts.yml |
| 123 | + with: |
| 124 | + version: ${{ needs.validate-inputs.outputs.VERSION }}rc${{ needs.validate-inputs.outputs.RC }} |
| 125 | + |
| 126 | + # PyPi |
| 127 | + pypi-build-artifacts: |
| 128 | + needs: |
| 129 | + - validate-inputs |
| 130 | + - validate-library-version |
| 131 | + uses: ./.github/workflows/pypi-build-artifacts.yml |
| 132 | + with: |
| 133 | + version: ${{ needs.validate-inputs.outputs.VERSION }}rc${{ needs.validate-inputs.outputs.RC }} |
0 commit comments