Skip to content

Commit b22117b

Browse files
committed
add tag trigger
1 parent 76f61a6 commit b22117b

File tree

1 file changed

+56
-26
lines changed

1 file changed

+56
-26
lines changed

.github/workflows/python-release.yml

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,64 @@
2020
name: "Python Build Release Candidate"
2121

2222
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]+'
2328
workflow_dispatch:
2429
inputs:
2530
version:
26-
description: 'Version (e.g, 0.8.0)'
31+
description: 'Version (e.g., 0.8.0)'
2732
type: string
2833
required: true
2934
rc:
30-
description: 'Release Candidate (RC) (e.g, rc1)'
35+
description: 'Release Candidate (RC) (e.g., rc1)'
3136
type: string
3237
required: true
3338

34-
env:
35-
RELEASE_CANDIDATE: "${{ github.event.inputs.version }}${{ github.event.inputs.rc }}"
36-
3739
jobs:
3840
validate-inputs:
3941
runs-on: ubuntu-latest
4042
steps:
41-
- name: Validate Input Version and RC
42-
id: validate
43+
- name: Validate and Extract Version and RC
4344
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"
4950
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
5471
fi
5572
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
5778
run: |
58-
echo "Running Release Candidate Version: $RELEASE_CANDIDATE"
79+
echo "Using Version: $VERSION"
80+
echo "Using RC: $RC"
5981
6082
validate-library-version:
6183
runs-on: ubuntu-latest
@@ -73,17 +95,16 @@ jobs:
7395
pip install poetry
7496
7597
- name: Validate current pyiceberg version
98+
env:
99+
VERSION: ${{ env.VERSION }}
76100
run: |
77101
# Extract the current version from Poetry
78102
current_pyiceberg_version=$(poetry version --short)
79103
echo "Detected Poetry version: $current_pyiceberg_version"
80104
81105
# 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)"
87108
exit 1
88109
fi
89110
@@ -154,8 +175,11 @@ jobs:
154175
steps:
155176
- name: Merge Artifacts
156177
uses: actions/upload-artifact/merge@v4
178+
env:
179+
VERSION: ${{ env.VERSION }}
180+
RC: ${{ env.RC }}
157181
with:
158-
name: "svn-release-candidate-${{ env.RELEASE_CANDIDATE }}"
182+
name: "svn-release-candidate-${VERSION}-rc${RC}"
159183
pattern: svn-release-candidate*
160184
delete-merged: true
161185

@@ -187,7 +211,10 @@ jobs:
187211
run: pip install poetry
188212

189213
- 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}"
191218

192219
# Publish the source distribution with the version that's in
193220
# the repository, otherwise the tests will fail
@@ -228,7 +255,10 @@ jobs:
228255
steps:
229256
- name: Merge Artifacts
230257
uses: actions/upload-artifact/merge@v4
258+
env:
259+
VERSION: ${{ env.VERSION }}
260+
RC: ${{ env.RC }}
231261
with:
232-
name: "pypi-release-candidate-${{ env.RELEASE_CANDIDATE }}"
262+
name: "pypi-release-candidate-${VERSION}-rc${RC}"
233263
pattern: pypi-release-candidate*
234264
delete-merged: true

0 commit comments

Comments
 (0)