Skip to content

Commit

Permalink
ci: Preparing to automate python packaging tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaminyam authored and jopemachine committed Jul 29, 2024
1 parent 03304fe commit 524d992
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 35 deletions.
62 changes: 27 additions & 35 deletions .github/workflows/deployment-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ name: PyPI Deployment

on:
push:
pull_request:
merge_group:
tags:
- "*"

jobs:
release-linux-x86_64:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
fail-fast: false
Expand All @@ -18,7 +17,7 @@ jobs:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout the source tree
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build the wheel
uses: PyO3/maturin-action@v1
env:
Expand All @@ -34,25 +33,22 @@ jobs:
manylinux: ${{ matrix.manylinux }}
target: ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-x86_64
path: binding/python/dist

release-linux-aarch64:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
runs-on: ubuntu-22.04-arm64
strategy:
fail-fast: false
matrix:
target: ["aarch64"]
manylinux: ["manylinux2014"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Checkout the source tree
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build the wheel
uses: PyO3/maturin-action@v1
env:
Expand All @@ -69,21 +65,20 @@ jobs:
manylinux: ${{ matrix.manylinux }}
target: ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-aarch64
path: binding/python/dist

release-macos:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: macos-latest
runs-on: macos-14
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout the source tree
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install prerequisites
run: |
brew install protobuf
Expand All @@ -93,49 +88,46 @@ jobs:
command: build
args: --release -m binding/python/Cargo.toml -o dist -i python${{ matrix.python-version }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-macos
path: binding/python/dist

release-source:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout the source tree
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python as Runtime
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build the source distribution
working-directory: binding/python
run: |
pip install -U pip setuptools
pip install -U build
python -m build --sdist
python -m build --sdist binding/python
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-source
path: binding/python/dist

publish-to-pypi:
needs: [release-linux-x86_64, release-linux-aarch64, release-macos, release-source]
environment: deploy-to-pypi
environment:
name: deploy-to-pypi
url: https://pypi.org/p/raftify
permissions:
id-token: write
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wheels
path: binding/python/dist
pattern: wheels-*
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: jopemachine
oidc: false
password: ${{ secrets.PYPI_API_TOKEN }}
repository-url: https://pypi.org/project/raftify/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build
dist

# Generated by Cargo
target
Expand Down

0 comments on commit 524d992

Please sign in to comment.