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: Add release to PyPI #30

Merged
merged 1 commit into from
Oct 12, 2023
Merged
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
99 changes: 90 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ concurrency:
cancel-in-progress: true

env:
PYTHON_VERSION: '3.8'
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
Expand Down Expand Up @@ -48,7 +49,45 @@ jobs:
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT

build-binaries:
create-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}

# Avoid potential out-of-memory errors
- name: Set swap space for Linux
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Create source distribution
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist

- name: Test sdist
run: |
TOOLCHAIN=$(grep -oP 'channel = "\K[^"]+' rust-toolchain.toml)
rustup default $TOOLCHAIN
pip install --force-reinstall --verbose dist/*.tar.gz
polars --version
python -m polars-cli --version

- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.tar.gz

build-wheels:
needs: get-version
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -59,8 +98,6 @@ jobs:
exclude:
- os: windows-latest
arch: aarch64
- os: ubuntu-latest
arch: aarch64

steps:
- uses: actions/checkout@v4
Expand All @@ -74,6 +111,11 @@ jobs:
with:
swap-size-gb: 10

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Set Rust target
id: target
run: |
Expand Down Expand Up @@ -101,12 +143,28 @@ jobs:
if: matrix.arch == 'aarch64' && matrix.os == 'ubuntu-latest'
run: echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV

- name: Build binary
run: cargo build --target ${{ steps.target.outputs.target }} --release
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ steps.target.outputs.target }}
args: >
--release
--out dist
manylinux: auto

- name: Test binary
- name: Test wheel
if: matrix.arch == 'x86_64'
run: ./target/${{ steps.target.outputs.target }}/release/polars --version
run: |
pip install dist/*.whl --force-reinstall
polars --version
python -m polars-cli --version

- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl

- name: Archive binary
id: archive
Expand All @@ -122,8 +180,31 @@ jobs:
name: binaries
path: ${{ steps.archive.outputs.filename }}

publish-to-pypi:
needs: [create-sdist, build-wheels]
environment:
name: release
url: https://pypi.org/project/polars-cli
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- name: Download wheels
uses: actions/download-artifact@v3
with:
name: wheels
path: dist

- name: Publish to PyPI
if: inputs.dry-run == false
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true

publish-to-crates-io:
needs: build-binaries
needs: [create-sdist, build-wheels]
environment:
name: release
url: https://crates.io/crates/polars-cli
Expand All @@ -140,7 +221,7 @@ jobs:
run: cargo publish ${{ inputs.dry-run && '--dry-run' || '' }}

publish-to-github:
needs: [publish-to-crates-io, get-version]
needs: [publish-to-pypi, publish-to-crates-io, get-version]
environment:
name: release
url: https://github.com/pola-rs/polars-cli/releases
Expand Down