20
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: <major>.<minor>.<patch>rc<release_candidate>
26
+ # Example valid tags: 0.8.1rc1, 1.0.0rc2
27
+ - ' [0-9]+.[0-9]+.[0-9]+rc[0-9]+'
23
28
workflow_dispatch :
24
29
inputs :
25
30
version :
26
- description : ' Version (e.g, 0.8.0)'
31
+ description : ' Version (e.g. , 0.8.0)'
27
32
type : string
28
33
required : true
29
34
rc :
30
- description : ' Release Candidate (RC) (e.g, rc1)'
35
+ description : ' Release Candidate (RC) (e.g. , rc1)'
31
36
type : string
32
37
required : true
33
38
34
- env :
35
- RELEASE_CANDIDATE : " ${{ github.event.inputs.version }}${{ github.event.inputs.rc }}"
36
-
37
39
jobs :
38
40
validate-inputs :
39
41
runs-on : ubuntu-latest
40
42
steps :
41
- - name : Validate Input Version and RC
42
- id : validate
43
+ - name : Validate and Extract Version and RC
43
44
run : |
44
- # Validate version (e.g., 1.0.0)
45
- if [[ ! "${{ github.event.inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
46
- echo "Error: version must be in the format number.number.number"
47
- exit 1
48
- fi
45
+ if [ "$GITHUB_EVENT_NAME" = "push" ]; then
46
+ echo "Workflow triggered by tag push."
47
+ TAG=${GITHUB_REF#refs/tags/} # Extract the tag name
48
+ VERSION=${TAG%rc*} # Extract version by removing everything after "rc"
49
+ RC=${TAG#*rc} # Extract RCby removing everything before "rc"
49
50
50
- # Validate rc (e.g., rc1)
51
- if [[ ! "${{ github.event.inputs.rc }}" =~ ^rc[0-9]+$ ]]; then
52
- echo "Error: rc must be in the format rc<number>"
53
- exit 1
51
+ if [[ -z "$VERSION" || -z "$RC" ]]; then
52
+ echo "Error: Unable to parse VERSION or RC from tag ($TAG). Ensure the tag format is correct."
53
+ exit 1
54
+ fi
55
+ else
56
+ echo "Workflow triggered manually via workflow_dispatch."
57
+ VERSION="${{ github.event.inputs.version }}"
58
+ RC="${{ github.event.inputs.rc }}"
59
+
60
+ # Validate version (e.g., 1.0.0)
61
+ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
62
+ echo "Error: version ($VERSION) must be in the format <number>.<number>.<number>"
63
+ exit 1
64
+ fi
65
+
66
+ # Validate rc (e.g., rc1)
67
+ if [[ ! "$RC" =~ ^rc[0-9]+$ ]]; then
68
+ echo "Error: rc ($RC) must be in the format rc<number>"
69
+ exit 1
70
+ fi
54
71
fi
55
72
56
- - name : Echo Release Candidate Version
73
+ # Export variables for future steps
74
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
75
+ echo "RC=$RC" >> $GITHUB_ENV
76
+
77
+ - name : Display Extracted Version and RC
57
78
run : |
58
- echo "Running Release Candidate Version: $RELEASE_CANDIDATE"
79
+ echo "Using Version: $VERSION"
80
+ echo "Using RC: $RC"
59
81
60
82
validate-library-version :
61
83
runs-on : ubuntu-latest
@@ -73,17 +95,16 @@ jobs:
73
95
pip install poetry
74
96
75
97
- name : Validate current pyiceberg version
98
+ env :
99
+ VERSION : ${{ env.VERSION }}
76
100
run : |
77
101
# Extract the current version from Poetry
78
102
current_pyiceberg_version=$(poetry version --short)
79
103
echo "Detected Poetry version: $current_pyiceberg_version"
80
104
81
105
# Compare the input version with the Poetry version
82
- input_version="${{ github.event.inputs.version }}"
83
-
84
- # Check if the input version matches the Poetry version
85
- if [[ "$input_version" != "$current_pyiceberg_version" ]]; then
86
- echo "Error: Input version ($input_version) does not match the Poetry version ($current_pyiceberg_version)"
106
+ if [[ "$VERSION" != "$current_pyiceberg_version" ]]; then
107
+ echo "Error: Input version ($VERSION) does not match the Poetry version ($current_pyiceberg_version)"
87
108
exit 1
88
109
fi
89
110
@@ -154,8 +175,11 @@ jobs:
154
175
steps :
155
176
- name : Merge Artifacts
156
177
uses : actions/upload-artifact/merge@v4
178
+ env :
179
+ VERSION : ${{ env.VERSION }}
180
+ RC : ${{ env.RC }}
157
181
with :
158
- name : " svn-release-candidate-${{ env.RELEASE_CANDIDATE } }"
182
+ name : " svn-release-candidate-${VERSION}-rc${RC }"
159
183
pattern : svn-release-candidate*
160
184
delete-merged : true
161
185
@@ -187,7 +211,10 @@ jobs:
187
211
run : pip install poetry
188
212
189
213
- name : Set version with RC
190
- run : python -m poetry version "${{ env.RELEASE_CANDIDATE }}"
214
+ env :
215
+ VERSION : ${{ env.VERSION }}
216
+ RC : ${{ env.RC }}
217
+ run : python -m poetry version "${VERSION}-rc${RC}"
191
218
192
219
# Publish the source distribution with the version that's in
193
220
# the repository, otherwise the tests will fail
@@ -228,7 +255,10 @@ jobs:
228
255
steps :
229
256
- name : Merge Artifacts
230
257
uses : actions/upload-artifact/merge@v4
258
+ env :
259
+ VERSION : ${{ env.VERSION }}
260
+ RC : ${{ env.RC }}
231
261
with :
232
- name : " pypi-release-candidate-${{ env.RELEASE_CANDIDATE } }"
262
+ name : " pypi-release-candidate-${VERSION}-rc${RC }"
233
263
pattern : pypi-release-candidate*
234
264
delete-merged : true
0 commit comments