Skip to content

Python Build Release Candidate #41

Python Build Release Candidate

Python Build Release Candidate #41

#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
name: "Python Release"
on:
workflow_dispatch:
inputs:
version:
description: 'Version (e.g, 0.8.0)'
type: string
required: true
rc:
description: 'Release candidate (RC) (e.g, rc1)'
type: string
required: true
jobs:
validate-inputs:
runs-on: ubuntu-latest
steps:
- name: Validate Version and RC
id: validate
run: |
# Validate version (e.g., 1.0.0)
if [[ ! "${{ github.event.inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: version must be in the format number.number.number"
exit 1
fi
# Validate rc (e.g., rc1)
if [[ ! "${{ github.event.inputs.rc }}" =~ ^rc[0-9]+$ ]]; then
echo "Error: rc must be in the format rc<number>"
exit 1
fi
- name: Release Version
run: |
echo "Running Release Version: ${{ github.event.inputs.version }}${{ github.event.inputs.rc }}"
validate-library-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Poetry
run: |
pip install poetry
- name: Validate current pyiceberg version
run: |
# Extract the current version from Poetry
current_pyiceberg_version=$(poetry version --short)
echo "Detected Poetry version: $current_pyiceberg_version"
# Compare the input version with the Poetry version
input_version="${{ github.event.inputs.version }}"
# Check if the input version matches the Poetry version
if [[ "$input_version" != "$current_pyiceberg_version" ]]; then
echo "Error: Input version ($input_version) does not match the Poetry version ($current_pyiceberg_version)"
exit 1
fi
build_svn_artifacts:
name: Build artifacts for SVN on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs:
- validate-inputs
- validate-library-version
strategy:
matrix:
os: [ ubuntu-22.04, windows-2022, macos-13, macos-14, macos-15 ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: |
3.9
3.10
3.11
3.12
- name: Install poetry
run: pip install poetry
# Publish the source distribution with the version that's in
# the repository, otherwise the tests will fail
- name: Compile source distribution
run: python3 -m poetry build --format=sdist
if: startsWith(matrix.os, 'ubuntu')
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: svn_wheelhouse
config-file: "pyproject.toml"
env:
# Ignore 32 bit architectures
CIBW_ARCHS: "auto64"
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9,<3.13"
CIBW_TEST_REQUIRES: "pytest==7.4.2 moto==5.0.1"
CIBW_TEST_EXTRAS: "s3fs,glue"
CIBW_TEST_COMMAND: "pytest {project}/tests/avro/test_decoder.py"
# There is an upstream issue with installing on MacOSX
# https://github.com/pypa/cibuildwheel/issues/1603
# Ignore tests for pypy since not all dependencies are compiled for it
# and would require a local rust build chain
CIBW_TEST_SKIP: "pp* *macosx*"
- name: Add source distribution
if: startsWith(matrix.os, 'ubuntu')
run: ls -lah dist/* && cp dist/* svn_wheelhouse/
- name: Generate SHA512 checksums
if: startsWith(matrix.os, 'ubuntu')
run: |
cd svn_wheelhouse
for name in $(ls pyiceberg-*.whl pyiceberg-*.tar.gz)
do
shasum -a 512 "${name}" > "${name}.sha512"
done
- name: Import GPG Key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@111c56156bcc6918c056dbef52164cfa583dc549
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Generate GPG signatures
if: startsWith(matrix.os, 'ubuntu')
run: |
cd svn_wheelhouse
for name in $(ls pyiceberg-*.whl pyiceberg-*.tar.gz)
do
gpg --yes --armor --output "${name}.asc" --detach-sig "${name}"
done
- uses: actions/upload-artifact@v4
with:
name: "release-svn-${{ matrix.os }}"
path: ./svn_wheelhouse/*
build_pypi_artifacts:
name: Build artifacts for PyPi on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs:
- validate-inputs
- validate-library-version
strategy:
matrix:
os: [ ubuntu-22.04, windows-2022, macos-13, macos-14, macos-15 ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: |
3.9
3.10
3.11
3.12
- name: Install poetry
run: pip install poetry
- name: Set version with RC
run: python -m poetry version "${{ github.event.inputs.version }}${{ github.event.inputs.rc }}"
# Publish the source distribution with the version that's in
# the repository, otherwise the tests will fail
- name: Compile source distribution
run: python3 -m poetry build --format=sdist
if: startsWith(matrix.os, 'ubuntu')
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: pypi_wheelhouse
config-file: "pyproject.toml"
env:
# Ignore 32 bit architectures
CIBW_ARCHS: "auto64"
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9,<3.13"
CIBW_TEST_REQUIRES: "pytest==7.4.2 moto==5.0.1"
CIBW_TEST_EXTRAS: "s3fs,glue"
CIBW_TEST_COMMAND: "pytest {project}/tests/avro/test_decoder.py"
# There is an upstream issue with installing on MacOSX
# https://github.com/pypa/cibuildwheel/issues/1603
# Ignore tests for pypy since not all dependencies are compiled for it
# and would require a local rust build chain
CIBW_TEST_SKIP: "pp* *macosx*"
- name: Add source distribution
if: startsWith(matrix.os, 'ubuntu')
run: ls -lah dist/* && cp dist/* pypi_wheelhouse/
- uses: actions/upload-artifact@v4
with:
name: "release-pypi-${{ matrix.os }}"
path: ./pypi_wheelhouse/*
merge_svn_artifacts:
runs-on: ubuntu-latest
needs: build_svn_artifacts
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: "release-svn-${{ github.event.inputs.version }}${{ github.event.inputs.rc }}"
pattern: release-svn*
delete-merged: true
merge_pypi_artifacts:
runs-on: ubuntu-latest
needs: build_pypi_artifacts
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: "release-pypi-${{ github.event.inputs.version }}${{ github.event.inputs.rc }}"
pattern: release-pypi*
delete-merged: true