Skip to content

removed dynamic __version__ + add wheels for python 3.10,11 #49

removed dynamic __version__ + add wheels for python 3.10,11

removed dynamic __version__ + add wheels for python 3.10,11 #49

name: Build and Publish python version
on:
push:
branches:
- main
# tags:
# - "v*.*.*" # Optional: only run on version tags
# pull_request:
# branches:
# - main
jobs:
create-dist:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
# - name: Create source distribution
# uses: PyO3/maturin-action@v1
# with:
# command: sdist
# args: >
# --manifest-path Cargo.toml
# --out dist
- name: Build with maturin
run: |
python -m pip install --upgrade pip
pip install --upgrade maturin==1.8.7
maturin sdist --manifest-path Cargo.toml --out dist
- name: Inspect Source Distribution
run: |
for file in dist/*.tar.gz; do
echo "Inspecting $file"
tar --wildcards -tzf "$file" | grep PKG-INFO || echo "PKG-INFO not found"
tar --wildcards -xOf "$file" */PKG-INFO || echo "Unable to read PKG-INFO"
done
- name: Test sdist
run: |
python -m pip install --upgrade pip
pip install --upgrade --force-reinstall twine
twine check dist/*.tar.gz
pip install --force-reinstall --verbose dist/*.tar.gz
python -c 'from polodb import PoloDB'
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
build:
runs-on: ${{ matrix.os }}
needs: create-dist
strategy:
matrix:
os: [ubuntu-latest, macos-14, macos-latest, windows-latest]
# os: [macos-14]
python-version: ["3.9", "3.10", "3.11"] # , "3.10"
architecture: [x86_64, aarch64] # Explicitly define architectures
# architecture: [aarch64] # Explicitly define architectures
exclude:
- os: windows-latest
architecture: aarch64
- os: macos-latest
architecture: aarch64 # macOS 13 on GitHub Actions is only x86_64 (Intel)
- os: macos-14
architecture: x86_64
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# - name: Create source distribution
# uses: PyO3/maturin-action@v1
# with:
# command: build
# args: >
# --manifest-path Cargo.toml
# --profile dist-release
# --out target/wheels
- name: Create source distribution
run: |
python -m pip install --upgrade pip
pip install --upgrade maturin==1.8.7
maturin build --manifest-path Cargo.toml --profile dist-release --out target/wheels
- name: Extract Version from pyproject.toml
id: get_version
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
VERSION=$(grep -m 1 version pyproject.toml | sed 's/.*version *= *"*\([^"]*\)"*/\1/')
else
VERSION=$(grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Print Version
run: |
echo "The current version is ${{ env.VERSION }}"
- name: Upload Artifact with OS and Architecture Tags
uses: actions/upload-artifact@v4
with:
name: polodb_python-${{env.VERSION}}-${{ matrix.os }}-${{ matrix.architecture }}-python${{matrix.python-version}}
path: target/wheels/*
publish:
needs: build # Ensure it runs after build job
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
# - name: Download Artifacts
# uses: actions/download-artifact@v4
# with:
# name: sdist
# path: dist # Download to dist/ directory
- name: Download Wheel Artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Inspect Generated PKG-INFO
run: |
for file in artifacts/**/*.tar.gz; do
echo "Inspecting $file"
tar -tzf "$file" | grep PKG-INFO || echo "PKG-INFO not found"
tar -xOf "$file" */PKG-INFO || echo "Unable to read PKG-INFO"
done
- name: Install Twine
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel twine maturin
- name: Upload to PyPI with Twine
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
ls -R artifacts/
twine check artifacts/**/*.tar.gz
twine upload artifacts/**/*.tar.gz
twine check artifacts/**/*.whl
for file in artifacts/**/*.whl; do
if [[ -f "$file" ]]; then
echo "Uploading $file..."
twine upload "$file" || echo "Failed to upload $file"
fi
done
# twine upload artifacts/**/*.whl