@@ -7,6 +7,17 @@ name: Python CI and library release
77
88on :
99 workflow_dispatch :
10+ inputs :
11+ pypi_release :
12+ description : ' Make a PyPI release'
13+ required : true
14+ default : false
15+ type : boolean
16+ use_git_version :
17+ description : ' Use git-based version for nightly builds'
18+ required : true
19+ default : true
20+ type : boolean
1021 schedule :
1122 # run every day at 4am
1223 - cron : ' 0 4 * * *'
@@ -23,8 +34,47 @@ defaults:
2334 working-directory : ./icechunk-python
2435
2536jobs :
37+ version :
38+ name : Generate dynamic version
39+ runs-on : ubuntu-latest
40+ outputs :
41+ version : ${{ steps.version.outputs.version }}
42+ steps :
43+ - uses : actions/checkout@v5
44+ with :
45+ fetch-depth : 0 # Need full history for git describe
46+
47+ - name : Generate version
48+ id : version
49+ run : |
50+ if [[ "${{ github.event_name }}" == "schedule" ]] || [[ "${{ inputs.use_git_version }}" == "true" ]]; then
51+ # For nightly builds, use component-based git describe approach
52+
53+ # Verify we have proper git tags
54+ if ! git describe --tags --match "v*" >/dev/null 2>&1; then
55+ echo "❌ ERROR: No version tags found. Please create a tag like 'v1.0.0' first."
56+ exit 1
57+ fi
58+
59+ # Get components from git (much simpler than parsing)
60+ TAG=$(git describe --tags --match 'v*' --abbrev=0 | sed 's/^v//')
61+ DISTANCE=$(git rev-list $(git describe --tags --match 'v*' --abbrev=0)..HEAD --count)
62+ HASH=$(git rev-parse --short HEAD)
63+
64+ # Build PEP 440 compliant version (always use .dev format)
65+ VERSION="${TAG}.dev${DISTANCE}+g${HASH}"
66+ echo "Git version: ${TAG}, distance: ${DISTANCE}, hash: ${HASH}"
67+ echo "Using git-based version: $VERSION"
68+ else
69+ # For regular releases, use version from Cargo.toml
70+ VERSION=$(grep '^version = ' icechunk-python/Cargo.toml | sed 's/version = "\(.*\)"/\1/')
71+ echo "Using Cargo.toml version: $VERSION"
72+ fi
73+ echo "version=$VERSION" >> $GITHUB_OUTPUT
74+
2675 linux :
2776 runs-on : ${{ matrix.platform.runner }}
77+ needs : version
2878 strategy :
2979 matrix :
3080 platform :
@@ -56,6 +106,10 @@ jobs:
56106 - uses : actions/setup-python@v6
57107 with :
58108 python-version : ' 3.11'
109+ - name : Update version in Cargo.toml
110+ if : ${{ github.event_name == 'schedule' || inputs.use_git_version == true }}
111+ run : |
112+ sed -i 's/^version = ".*"/version = "${{ needs.version.outputs.version }}"/' Cargo.toml
59113 - name : Build wheels
60114 uses : PyO3/maturin-action@v1
61115 with :
71125
72126 musllinux :
73127 runs-on : ${{ matrix.platform.runner }}
128+ needs : version
74129 strategy :
75130 matrix :
76131 platform :
@@ -87,6 +142,10 @@ jobs:
87142 - uses : actions/setup-python@v6
88143 with :
89144 python-version : 3.x
145+ - name : Update version in Cargo.toml
146+ if : ${{ github.event_name == 'schedule' || inputs.use_git_version == true }}
147+ run : |
148+ sed -i 's/^version = ".*"/version = "${{ needs.version.outputs.version }}"/' Cargo.toml
90149 - name : Build wheels
91150 uses : PyO3/maturin-action@v1
92151 with :
@@ -102,6 +161,7 @@ jobs:
102161
103162 windows :
104163 runs-on : ${{ matrix.platform.runner }}
164+ needs : version
105165 strategy :
106166 matrix :
107167 platform :
@@ -115,6 +175,11 @@ jobs:
115175 with :
116176 python-version : 3.x
117177 architecture : ${{ matrix.platform.target }}
178+ - name : Update version in Cargo.toml
179+ if : ${{ github.event_name == 'schedule' || inputs.use_git_version == true }}
180+ run : |
181+ (Get-Content Cargo.toml) -replace '^version = ".*"', 'version = "${{ needs.version.outputs.version }}"' | Set-Content Cargo.toml
182+ shell : powershell
118183 - name : Build wheels
119184 uses : PyO3/maturin-action@v1
120185 with :
@@ -129,6 +194,7 @@ jobs:
129194
130195 macos :
131196 runs-on : ${{ matrix.platform.runner }}
197+ needs : version
132198 strategy :
133199 matrix :
134200 platform :
@@ -141,6 +207,10 @@ jobs:
141207 - uses : actions/setup-python@v6
142208 with :
143209 python-version : 3.x
210+ - name : Update version in Cargo.toml
211+ if : ${{ github.event_name == 'schedule' || inputs.use_git_version == true }}
212+ run : |
213+ sed -i '' 's/^version = ".*"/version = "${{ needs.version.outputs.version }}"/' Cargo.toml
144214 - name : Build wheels
145215 uses : PyO3/maturin-action@v1
146216 with :
@@ -155,8 +225,13 @@ jobs:
155225
156226 sdist :
157227 runs-on : ubuntu-latest
228+ needs : version
158229 steps :
159230 - uses : actions/checkout@v5
231+ - name : Update version in Cargo.toml
232+ if : ${{ github.event_name == 'schedule' || inputs.use_git_version == true }}
233+ run : |
234+ sed -i 's/^version = ".*"/version = "${{ needs.version.outputs.version }}"/' Cargo.toml
160235 - name : Build sdist
161236 uses : PyO3/maturin-action@v1
162237 with :
@@ -174,7 +249,7 @@ jobs:
174249 runs-on : ubuntu-latest
175250 permissions :
176251 id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
177- if : ${{ github.event_name == 'workflow_dispatch' }}
252+ if : ${{ github.event_name == 'workflow_dispatch' && inputs.pypi_release }}
178253 needs : [linux, musllinux, windows, macos, sdist]
179254 steps :
180255 - uses : actions/download-artifact@v5
0 commit comments