Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Improve pypi package release workflow #106

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 27 additions & 35 deletions .github/workflows/deployment-pypi.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
Loading