From 844507d1bc5279b3248f712cb45d65c740efcdfd Mon Sep 17 00:00:00 2001 From: Alessio Vertemati Date: Tue, 17 Sep 2024 15:18:13 +0200 Subject: [PATCH 1/5] wip: Build and Release --- .github/workflows/release.yml | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) 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..c07d22c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +name: Publish on PyPI + +on: + pull_request: + types: [opened, synchronize, reopened] + 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 + path: build/* + + 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: build + + - name: Display structure of downloaded files + run: ls -R build + + # - 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: + # repository-url: https://test.pypi.org/legacy/ + # print-hash: true + # verbose: true \ No newline at end of file From 3ffad130c7edd017ea882f105c21f147debb9b6b Mon Sep 17 00:00:00 2001 From: Alessio Vertemati Date: Tue, 17 Sep 2024 15:26:09 +0200 Subject: [PATCH 2/5] Test publication on Test PyPI --- .github/workflows/release.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c07d22c..84c1b3a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: parse_model_release - path: build/* + path: dist/* pypi-publish: name: Upload release to PyPI @@ -53,15 +53,15 @@ jobs: uses: actions/download-artifact@v4 with: name: parse_model_release - path: build + path: dist - name: Display structure of downloaded files - run: ls -R build + run: ls -R 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: - # repository-url: https://test.pypi.org/legacy/ - # print-hash: true - # verbose: true \ No newline at end of file + - 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: + repository-url: https://test.pypi.org/legacy/ + print-hash: true + verbose: true \ No newline at end of file From 278e094754bbd6bc1bfda080c70145eda037cd76 Mon Sep 17 00:00:00 2001 From: Alessio Vertemati Date: Tue, 17 Sep 2024 15:31:41 +0200 Subject: [PATCH 3/5] Fix naming --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c137cd4..771b31c 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ long_description = f.read() setup( - name='document-model-python', + name='parse-document-model', version='0.1.0', description='Pydantic models for representing a text document as a hierarchical structure.', long_description=long_description, From 41cad17a3684e2c9d19705058aeaddafd60c63a5 Mon Sep 17 00:00:00 2001 From: Alessio Vertemati Date: Tue, 17 Sep 2024 15:46:00 +0200 Subject: [PATCH 4/5] Test publication on PyPI --- .github/workflows/release.yml | 9 +++------ setup.py | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84c1b3a..64bcd4a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,8 @@ jobs: uses: actions/upload-artifact@v4 with: name: parse_model_release + if-no-files-found: error + retention-days: 1 path: dist/* pypi-publish: @@ -54,14 +56,9 @@ jobs: with: name: parse_model_release path: dist - - - name: Display structure of downloaded files - run: ls -R 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: - repository-url: https://test.pypi.org/legacy/ - print-hash: true - verbose: true \ No newline at end of file + print-hash: true \ No newline at end of file diff --git a/setup.py b/setup.py index 771b31c..ba49743 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='parse-document-model', - version='0.1.0', + version='0.0.1', description='Pydantic models for representing a text document as a hierarchical structure.', long_description=long_description, long_description_content_type='text/markdown', From 14cc54478068203cc7649fcf2755fea785524679 Mon Sep 17 00:00:00 2001 From: Alessio Vertemati Date: Tue, 17 Sep 2024 15:51:30 +0200 Subject: [PATCH 5/5] Prepare for tags only --- .github/workflows/release.yml | 7 ++++--- setup.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64bcd4a..f17aa95 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,9 @@ name: Publish on PyPI on: - pull_request: - types: [opened, synchronize, reopened] + push: + branches: + - "main" release: types: [created] @@ -59,6 +60,6 @@ jobs: - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + 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 ba49743..322941f 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='parse-document-model', - version='0.0.1', + 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',