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

[MNT] improved release workflow #1657

Merged
merged 2 commits into from
Sep 8, 2024
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
82 changes: 67 additions & 15 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,81 @@ on:
types: [published]

jobs:
build:
build_wheels:
name: Build wheels
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: '3.11'

- name: Install poetry
shell: bash
- name: Build wheel
run: |
curl -sSL https://install.python-poetry.org | python3 -
python -m pip install poetry-dynamic-versioning[plugin]
python -m pip install build
python -m build --wheel --sdist --outdir wheelhouse

- name: Store wheels
uses: actions/upload-artifact@v4
with:
name: wheels
path: wheelhouse/*

pytest-nosoftdeps:
name: no-softdeps
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

- name: Set poetry path variable
run: echo "/Users/runner/.local/bin" >> $GITHUB_PATH
steps:
- uses: actions/checkout@v4

- name: Build
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Setup macOS
if: runner.os == 'macOS'
run: |
poetry build
brew install libomp # https://github.com/pytorch/pytorch/issues/20030

- name: Publish distribution 📦 to PyPI
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
- name: Get full Python version
id: full-python-version
shell: bash
run: echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT

- name: Install dependencies
shell: bash
run: |
poetry publish --username "${{ secrets.PYPI_USER }}" --password "${{ secrets.PYPI_PASSWORD }}"
pip install ".[dev,github-actions]"

- name: Show dependencies
run: python -m pip list

- name: Run pytest
shell: bash
run: python -m pytest tests

upload_wheels:
name: Upload wheels to PyPI
runs-on: ubuntu-latest
needs: [pytest-nosoftdeps]

steps:
- uses: actions/download-artifact@v4
with:
name: wheels
path: wheelhouse

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USER }}
password: ${{ secrets.PYPI_PASSWORD }}
packages-dir: wheelhouse/
Loading