Skip to content

Commit

Permalink
fix(python-bindings)
Browse files Browse the repository at this point in the history
update github workflows
  • Loading branch information
Hamza SENHAJI RHAZI authored and Hamza SENHAJI RHAZI committed Nov 11, 2024
1 parent 8fa5f9e commit a273dcf
Showing 1 changed file with 114 additions and 108 deletions.
222 changes: 114 additions & 108 deletions .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,111 +11,117 @@ on:
- 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: Test sdist
run: |
python -m pip install --upgrade pip
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-latest, windows-latest]
python-version: ["3.9", "3.10"]
architecture: [x86_64, aarch64] # Explicitly define architectures
exclude:
- os: windows-latest
architecture: aarch64 # Skip aarch64 on W

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: Extract Version from pyproject.toml
id: get_version
run: |
VERSION=$(grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
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 }}
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: dist-artifact
path: dist # Download to dist/ directory

- name: Download Wheel Artifacts
uses: actions/download-artifact@v4
with:
name: wheels-artifact
path: target/wheels # Download to target/wheels directory

- name: Install Twine
run: |
python -m pip install --upgrade pip
pip install twine
- name: Upload to PyPI with Twine
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/* target/wheels/*
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: Test sdist
run: |
python -m pip install --upgrade pip
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, windows-latest]
os: [macos-14]
# python-version: ["3.9", "3.10"]
python-version: ["3.10"]
# architecture: [x86_64, aarch64] # Explicitly define architectures
architecture: [aarch64] # Explicitly define architectures
exclude:
- os: windows-latest
architecture: aarch64

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: 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: Install Twine
run: |
python -m pip install --upgrade pip
pip install twine
- name: Upload to PyPI with Twine
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
ls -R artifacts/
twine upload artifacts/**/*.tar.gz artifacts/**/*.whl

0 comments on commit a273dcf

Please sign in to comment.