Skip to content

Commit

Permalink
Fix PyPi publishing (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
knielsen404 authored Feb 21, 2025
1 parent 78b1aea commit d31f015
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
42 changes: 33 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,58 @@
name: Publish to PyPI

on:
push:
tags:
- 'v*'
workflow_run:
workflows:
- Invariant testing CI
types:
- completed
branches:
- v*

jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
runs-on: ubuntu-latest
environment: pypi-package
if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref_type == 'tag' }}

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.12.2
uses: actions/setup-python@v3
with:
python-version: "3.12.2"

- name: Setup dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
pip install poetry==2.1.1
poetry install
- name: Build package
run: |
poetry build
# Install invariant package in a virtual environment for testing
- name: Create virtual environment and install package
run: |
python -m venv venv
source venv/bin/activate
pip install dist/*.whl
# Make sure the tests pass when the package is built and installed
- name: Run tests
env:
OPENAI_API_KEY: ${{ secrets.INVARIANT_TESTING_OPENAI_KEY }}
run: |
source venv/bin/activate
python -m pytest invariant/tests/
- name: Set PyPI credentials
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
- name: Publish to PyPI
run: |
poetry publish --build
poetry publish --dist-dir dist
10 changes: 2 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,5 @@ testpaths = ["invariant/tests"]
invariant = "invariant.__main__:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["invariant"]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit d31f015

Please sign in to comment.