Skip to content

feat : add version file #21

feat : add version file

feat : add version file #21

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: 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, macos-13, windows-latest]
# os: [macos-14]
python-version: ["3.9"] # , "3.10"
# python-version: ["3.10"]
architecture: [x86_64, arm64] # Explicitly define architectures
# architecture: [aarch64] # Explicitly define architectures
exclude:
- os: windows-latest
architecture: arm64
- os: macos-13
architecture: arm64 # macOS 13 on GitHub Actions is only x86_64 (Intel)
- os: macos-14
architecture: x86_6
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
twine upload artifacts/**/*.whl