From 34f1720fa5178506cdefd4660d572eeb5fb8da56 Mon Sep 17 00:00:00 2001 From: Alessio Date: Tue, 17 Sep 2024 15:55:27 +0200 Subject: [PATCH] Build and Release on PyPI (#3) --- .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++++ setup.py | 4 +-- 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f17aa95 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +name: Publish on PyPI + +on: + push: + branches: + - "main" + release: + types: [created] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: pip + cache-dependency-path: | + **/setup.py + **/requirements*.txt + + - name: Install dependencies + run: | + pip install -r requirements.txt -r requirements-dev.txt + + - name: Build wheel + run: | + python setup.py sdist bdist_wheel + twine check dist/* + + - name: Upload build for publishing + uses: actions/upload-artifact@v4 + with: + name: parse_model_release + if-no-files-found: error + retention-days: 1 + path: dist/* + + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + needs: build + environment: release + permissions: + id-token: write + steps: + - name: Download math result for job 1 + uses: actions/download-artifact@v4 + with: + name: parse_model_release + path: dist + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + with: + print-hash: true \ No newline at end of file diff --git a/setup.py b/setup.py index c137cd4..322941f 100644 --- a/setup.py +++ b/setup.py @@ -9,8 +9,8 @@ long_description = f.read() setup( - name='document-model-python', - version='0.1.0', + name='parse-document-model', + version='0.0.2', description='Pydantic models for representing a text document as a hierarchical structure.', long_description=long_description, long_description_content_type='text/markdown',