From 05bee94f1cbbd234c958e37da0a3c32dd4ead3ff Mon Sep 17 00:00:00 2001 From: Nicholas Junge Date: Tue, 16 Jan 2024 11:51:54 +0100 Subject: [PATCH] Add PyPI publishing job for mlbench Uses `build` as a build frontend and trusted publishing for uploads. Also updates pre-commit hooks. --- .github/workflows/release.yaml | 52 ++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..0e44dda --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,52 @@ +name: Build and publish Python wheel and sdist + +on: + workflow_dispatch: + release: + types: + - published + +jobs: + build: + name: Build source distribution and wheel + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python and dependencies + uses: actions/setup-python@v4 + with: + python-version: 3.11 + cache: pip + cache-dependency-path: | + requirements-dev.txt + pyproject.toml + - name: Build and check + run: | + python -m build + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist + publish_pypi: + name: Publish wheels to PyPI + needs: [build] + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: dist + path: dist + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip-existing: true # tolerate release package file duplicates + repository-url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e8615fa..9992d04 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: types_or: [ python, pyi ] args: [--ignore-missing-imports, --scripts-are-modules] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.11 + rev: v0.1.13 hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ]