Skip to content

Commit b47af2d

Browse files
authored
[infra] add testpypi nightly build (#1601)
Closes #872 This PR adds the ability to run and publish pypi artifacts nightly to testpypi. It will publish as `pyiceberg` with new version under `0.9.0.dev${TIMESTAMP}`, i.e. `0.9.0.dev20250206050843`, adhering to PEP440 conversion. Here's a [test run on my fork](https://github.com/kevinjqliu/iceberg-python/actions/runs/13172235318) which published to https://test.pypi.org/project/pyiceberg-kevinliu/ This requires setting up [Publishing to PyPI with a Trusted Publisher](https://docs.pypi.org/trusted-publishers/) on https://test.pypi.org/ and using example of publishing [pyiceberg_core](https://github.com/apache/iceberg-rust/blob/8714ffd69c411990a89e1c3f03b51c33670f18ec/.github/workflows/release_python.yml#L120-L146) to testpypi Note, this PR also refactors `.github/workflows/python-release.yml`, i've [ran the workflow on my fork](https://github.com/kevinjqliu/iceberg-python/actions/runs/13172075517) and manually verified the version for both pypi and svn artifacts. Setup trusted publisher on testpypi for apache/iceberg-python repo https://test.pypi.org/manage/project/pyiceberg/settings/publishing/
1 parent 4d648bb commit b47af2d

File tree

4 files changed

+92
-16
lines changed

4 files changed

+92
-16
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
name: "Nightly PyPI Build"
21+
22+
on:
23+
schedule:
24+
- cron: "0 0 * * *" # Runs at midnight UTC every day
25+
workflow_dispatch: # Allows manual triggering
26+
27+
jobs:
28+
set-version:
29+
if: github.repository == 'apache/iceberg-python' # Only run for apache repo
30+
runs-on: ubuntu-latest
31+
outputs:
32+
VERSION: ${{ steps.set-version.outputs.VERSION }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 1
37+
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: 3.12
41+
42+
- name: Install Poetry
43+
run: make install-poetry
44+
45+
- name: Set version
46+
id: set-version
47+
run: |
48+
CURRENT_VERSION=$(poetry version --short)
49+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
50+
echo "VERSION=${CURRENT_VERSION}.dev${TIMESTAMP}" >> "$GITHUB_OUTPUT"
51+
52+
- name: Debug version
53+
run: echo "Publishing version ${{ steps.set-version.outputs.VERSION }}"
54+
55+
nightly-build:
56+
needs: set-version
57+
uses: ./.github/workflows/pypi-build-artifacts.yml
58+
with:
59+
version: ${{ needs.set-version.outputs.VERSION }}
60+
testpypi-publish:
61+
name: Publish to TestPypi
62+
needs:
63+
- nightly-build
64+
runs-on: ubuntu-latest
65+
environment:
66+
name: testpypi
67+
url: https://test.pypi.org/p/pyiceberg
68+
69+
permissions:
70+
id-token: write # IMPORTANT: mandatory for trusted publishing
71+
72+
steps:
73+
- name: Download all the artifacts
74+
uses: actions/download-artifact@v4
75+
with:
76+
merge-multiple: true
77+
path: dist/
78+
- name: List downloaded artifacts
79+
run: ls -R dist/
80+
- name: Publish to TestPyPI
81+
uses: pypa/gh-action-pypi-publish@release/v1
82+
with:
83+
repository-url: https://test.pypi.org/legacy/
84+
skip-existing: true
85+
verbose: true

.github/workflows/pypi-build-artifacts.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ on:
2525
VERSION:
2626
required: true
2727
type: string
28-
RC:
29-
required: true
30-
type: string
3128

3229
jobs:
3330
pypi-build-artifacts:
3431
name: Build artifacts for PyPi on ${{ matrix.os }}
3532
runs-on: ${{ matrix.os }}
3633
strategy:
3734
matrix:
38-
os: [ ubuntu-22.04, windows-2022, macos-13, macos-14, macos-15 ]
35+
os: [ ubuntu-22.04, windows-2022, macos-13, macos-14 ]
3936

4037
steps:
4138
- uses: actions/checkout@v4
@@ -56,8 +53,7 @@ jobs:
5653
- name: Set version with RC
5754
env:
5855
VERSION: ${{ inputs.VERSION }}
59-
RC: ${{ inputs.RC }}
60-
run: python -m poetry version "${{ env.VERSION }}rc${{ env.RC }}" # e.g., 0.8.0rc1
56+
run: python -m poetry version "${{ env.VERSION }}"
6157

6258
# Publish the source distribution with the version that's in
6359
# the repository, otherwise the tests will fail
@@ -97,6 +93,6 @@ jobs:
9793
- name: Merge Artifacts
9894
uses: actions/upload-artifact/merge@v4
9995
with:
100-
name: "pypi-release-candidate-${{ inputs.VERSION }}rc${{ inputs.RC }}"
96+
name: "pypi-release-candidate-${{ inputs.VERSION }}"
10197
pattern: pypi-release-candidate*
10298
delete-merged: true

.github/workflows/python-release.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ jobs:
121121
- validate-library-version
122122
uses: ./.github/workflows/svn-build-artifacts.yml
123123
with:
124-
version: ${{ needs.validate-inputs.outputs.VERSION }}
125-
rc: ${{ needs.validate-inputs.outputs.RC }}
124+
version: ${{ needs.validate-inputs.outputs.VERSION }}rc${{ needs.validate-inputs.outputs.RC }}
126125

127126
# PyPi
128127
pypi-build-artifacts:
@@ -131,5 +130,4 @@ jobs:
131130
- validate-library-version
132131
uses: ./.github/workflows/pypi-build-artifacts.yml
133132
with:
134-
version: ${{ needs.validate-inputs.outputs.VERSION }}
135-
rc: ${{ needs.validate-inputs.outputs.RC }}
133+
version: ${{ needs.validate-inputs.outputs.VERSION }}rc${{ needs.validate-inputs.outputs.RC }}

.github/workflows/svn-build-artifacts.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ on:
2525
VERSION:
2626
required: true
2727
type: string
28-
RC:
29-
required: true
30-
type: string
3128

3229
jobs:
3330
svn-build-artifacts:
3431
name: Build artifacts for SVN on ${{ matrix.os }}
3532
runs-on: ${{ matrix.os }}
3633
strategy:
3734
matrix:
38-
os: [ ubuntu-22.04, windows-2022, macos-13, macos-14, macos-15 ]
35+
os: [ ubuntu-22.04, windows-2022, macos-13, macos-14 ]
3936

4037
steps:
4138
- uses: actions/checkout@v4
@@ -91,6 +88,6 @@ jobs:
9188
- name: Merge Artifacts
9289
uses: actions/upload-artifact/merge@v4
9390
with:
94-
name: "svn-release-candidate-${{ inputs.VERSION }}rc${{ inputs.RC }}"
91+
name: "svn-release-candidate-${{ inputs.VERSION }}"
9592
pattern: svn-release-candidate*
9693
delete-merged: true

0 commit comments

Comments
 (0)