Skip to content

Commit a816ba3

Browse files
committed
add input validation
1 parent 46bbd6a commit a816ba3

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

.github/workflows/python-release.yml

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ on:
2525
version:
2626
description: 'Version'
2727
type: string
28+
required: true
2829
rc:
29-
description: 'RC'
30+
description: 'Release candidate (RC)'
3031
type: string
31-
32+
required: true
3233

3334
jobs:
3435
validate-inputs:
@@ -47,11 +48,42 @@ jobs:
4748
if [[ ! "${{ github.event.inputs.rc }}" =~ ^rc[0-9]+$ ]]; then
4849
echo "Error: rc must be in the format rc<number>"
4950
exit 1
51+
fi
5052
5153
- name: Release Version
5254
run: |
5355
echo "Running Release Version: ${{ github.event.inputs.version }}${{ github.event.inputs.rc }}"
5456
57+
validate-library-version:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 0
63+
64+
- uses: actions/setup-python@v5
65+
with:
66+
python-version: 3.12
67+
68+
- name: Install Poetry
69+
run: |
70+
pip install poetry
71+
72+
- name: Validate current pyiceberg version
73+
run: |
74+
# Extract the current version from Poetry
75+
current_pyiceberg_version=$(poetry version --short)
76+
echo "Detected Poetry version: $current_pyiceberg_version"
77+
78+
# Compare the input version with the Poetry version
79+
input_version="${{ github.event.inputs.version }}"
80+
81+
# Check if the input version matches the Poetry version
82+
if [[ "$input_version" != "$current_pyiceberg_version" ]]; then
83+
echo "Error: Input version ($input_version) does not match the Poetry version ($current_pyiceberg_version)"
84+
exit 1
85+
fi
86+
5587
build_svn_artifacts:
5688
name: Build artifacts for SVN on ${{ matrix.os }}
5789
runs-on: ${{ matrix.os }}
@@ -133,7 +165,7 @@ jobs:
133165
name: "release-svn-${{ matrix.os }}"
134166
path: ./svn_wheelhouse/*
135167

136-
build_pypi_artifacts: # pypi `tag` as version
168+
build_pypi_artifacts:
137169
name: Build artifacts for PyPi on ${{ matrix.os }}
138170
runs-on: ${{ matrix.os }}
139171
strategy:
@@ -156,8 +188,8 @@ jobs:
156188
- name: Install poetry
157189
run: pip install poetry
158190

159-
- name: Set version
160-
run: python -m poetry version "${{ github.event.inputs.version }}${{ github.event.inputs.rc }}" # CHANGE TO current TAG
191+
- name: Set version with RC
192+
run: python -m poetry version "${{ github.event.inputs.version }}${{ github.event.inputs.rc }}"
161193

162194
# Publish the source distribution with the version that's in
163195
# the repository, otherwise the tests will fail

0 commit comments

Comments
 (0)