From be7e9616d387daa5d511be6398e7ed453e40bd04 Mon Sep 17 00:00:00 2001 From: Ben Chambers <35960+bjchambers@users.noreply.github.com> Date: Thu, 1 Feb 2024 08:47:44 -0800 Subject: [PATCH 1/7] ci: Initial release workflows These are currently configured to publish `dewy` and `dewy-client` to test-pypi so that I can overwrite previous versions to verify it works. Once working, I can switch to `pypi` and/or add that as a separate step. We could actually run some tests against the package in `test-pypi` before publishing the artifcats to `pypi`. --- .github/workflows/README.md | 1 + .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 175 ++++++++++++++++++++++++++++++++++ .gitignore | 4 +- 4 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/README.md b/.github/workflows/README.md index ccd41db..ecb1802 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -9,6 +9,7 @@ We currently have the following workflows: 3. `site.yml` defines the build and deployment process for the site. 4. `release-drafter.yml`: Generates draft release notes as PRs are merged. 5. `sync-labels.yml`: Updates the labels in the project to match `.github/labels.yml`. +6. `release.yml`: Release automation triggered when a release is created. ## Future Improvements diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa79cbb..1df6f86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: run: | poetry run poe extract-openapi poetry run poe update-client - # Record intent to add any new files in client + # Record intent to add any new files in `dewy-client` git add -N dewy-client # Diff, and report any changes (including any new files in dewy-client) git diff --exit-code diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a59a900 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,175 @@ +name: Release + +# Only one release job at a time. +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: true + +# Triggered when a release is published.defaults: +# This happens when a draft (generated by release-drafter.yml) is published. +# +# This applies whether the published draft is marked "pre-release" or not. +# +# > NOTE: The prereleased type will not trigger for pre-releases published from +# > draft releases, but the published type will trigger. If you want a workflow +# > to run when stable and pre-releases publish, subscribe to published instead +# > of released and prereleased. +# > +# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release +on: + push: + branches: + - main + # DO NOT MERGE + pull_request: + release: + types: + - published + +# Generally limited permissions. +# We'll request write permission when needed for deployment. +permissions: + contents: read + +# Basic workflow from +# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#configuring-trusted-publishing +jobs: + build-dewy: + name: Build dewy (and dewy-client) distribution 📦 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Install poetry + uses: abatilo/actions-poetry@v2 + - name: Install the project dependencies + run: poetry install --with=dev + - name: Build dewy + run: | + poetry install --with-=dev + poetry build + - name: Store the dewy distribution packages + uses: actions/upload-artifact@v3 + with: + name: dewy-distributions + path: dist/ + - name: Build dewy-client + working-directory: dewy-client + run: | + poetry install + poetry build + - name: Store the dewy-client distribution packages + uses: actions/upload-artifact@v3 + with: + name: dewy-distributions + path: dist/ + + publish-dewy-to-test-pypi: + name: Publish dewy + # Only publish to PyPi on releases. + # if: github.event_name == 'release' && github.event.action == 'published' + needs: build-dewy + runs-on: ubuntu-latest + environment: + name: test-pypi + url: https://test.pypi.org/p/dewy + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download the dewy dist + uses: actions/download-artifact@v3 + with: + name: dewy-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + publish-dewy-client-to-test-pypi: + name: Publish dewy + # Only publish to PyPi on releases. + # if: github.event_name == 'release' && github.event.action == 'published' + needs: build-dewy + runs-on: ubuntu-latest + environment: + name: test-pypi + url: https://test.pypi.org/p/dewy-client + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download the dewy-client dist + uses: actions/download-artifact@v3 + with: + name: dewy-client-distributions + path: dewy-client/dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dewy-client/dist + + github-release: + name: Sign and finalize GitHub release + # Only publish on release. + if: github.event_name == 'release' && github.event.action == 'published' + needs: + - publish-dewy-to-test-pypi + - publish-dewy-client-to-test-pypi + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download the dewy dist + uses: actions/download-artifact@v3 + with: + name: dewy-distributions + path: dist/ + - name: Download the dewy-client dist + uses: actions/download-artifact@v3 + with: + name: dewy-client-distributions + path: dewy-client/dist/ + - name: Sign the dewy and dewy-client dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + ./dewy-client/dist/*.tar.gz + ./dewy-client/dist/*.whl + - name: Upload dewy artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' + + - name: Upload dewy-client artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dewy-client/dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dewy-client/dist/** + --repo '${{ github.repository }}' + + - name: Publish release + # TODO: Add --discussion-category "Announcements" to create a release discussion? + run: | + gh release edit ${{ github.ref_name }} \ + --draft=false --latest + env: + GH_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6150e7b..1a61a3a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .ruff_cache __pycache__ .env -.vscode/ \ No newline at end of file +.vscode/ +/dist +/dewy-client/dist \ No newline at end of file From 9c00081023ea036a1f0fbbec9c67cdf65846fe1d Mon Sep 17 00:00:00 2001 From: Ben Chambers <35960+bjchambers@users.noreply.github.com> Date: Thu, 1 Feb 2024 08:50:50 -0800 Subject: [PATCH 2/7] tweak names --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a59a900..42b2eb0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: path: dist/ publish-dewy-to-test-pypi: - name: Publish dewy + name: Publish dewy to test-pypi # Only publish to PyPi on releases. # if: github.event_name == 'release' && github.event.action == 'published' needs: build-dewy @@ -90,7 +90,7 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 publish-dewy-client-to-test-pypi: - name: Publish dewy + name: Publish dewy-client to test-pypi # Only publish to PyPi on releases. # if: github.event_name == 'release' && github.event.action == 'published' needs: build-dewy From 298ef2d77014d37a65cd9caee90c20d89d9a3c88 Mon Sep 17 00:00:00 2001 From: Ben Chambers <35960+bjchambers@users.noreply.github.com> Date: Thu, 1 Feb 2024 08:51:20 -0800 Subject: [PATCH 3/7] fix build --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 42b2eb0..c224a93 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,11 +46,9 @@ jobs: python-version: "3.11" - name: Install poetry uses: abatilo/actions-poetry@v2 - - name: Install the project dependencies - run: poetry install --with=dev - name: Build dewy run: | - poetry install --with-=dev + poetry install --with=dev poetry build - name: Store the dewy distribution packages uses: actions/upload-artifact@v3 From dfafd21405521ec0bac25b4fa23ad16a1abe91e1 Mon Sep 17 00:00:00 2001 From: Ben Chambers <35960+bjchambers@users.noreply.github.com> Date: Thu, 1 Feb 2024 08:58:39 -0800 Subject: [PATCH 4/7] fix test pypi --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c224a93..072eb84 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,6 +86,8 @@ jobs: path: dist/ - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ publish-dewy-client-to-test-pypi: name: Publish dewy-client to test-pypi @@ -109,6 +111,7 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dewy-client/dist + repository-url: https://test.pypi.org/legacy/ github-release: name: Sign and finalize GitHub release From 51f77302a876b40e909d8c238afd8342b539653c Mon Sep 17 00:00:00 2001 From: Ben Chambers <35960+bjchambers@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:29:18 -0800 Subject: [PATCH 5/7] fix dewy-client distribution --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 072eb84..1e92042 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,8 +63,8 @@ jobs: - name: Store the dewy-client distribution packages uses: actions/upload-artifact@v3 with: - name: dewy-distributions - path: dist/ + name: dewy-client-distributions + path: dewy-client/dist/ publish-dewy-to-test-pypi: name: Publish dewy to test-pypi From 3a5b686275706280b318bf074243f28c1aef248a Mon Sep 17 00:00:00 2001 From: Ben Chambers <35960+bjchambers@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:48:05 -0800 Subject: [PATCH 6/7] switch to prod pypi --- .github/workflows/release.yml | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e92042..f0c215e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,8 +20,6 @@ on: push: branches: - main - # DO NOT MERGE - pull_request: release: types: - published @@ -66,15 +64,17 @@ jobs: name: dewy-client-distributions path: dewy-client/dist/ - publish-dewy-to-test-pypi: - name: Publish dewy to test-pypi + publish-dewy-to-pypi: + name: Publish dewy to pypi # Only publish to PyPi on releases. - # if: github.event_name == 'release' && github.event.action == 'published' + if: github.event_name == 'release' && github.event.action == 'published' needs: build-dewy runs-on: ubuntu-latest environment: - name: test-pypi - url: https://test.pypi.org/p/dewy + # name: test-pypi + # url: https://test.pypi.org/p/dewy + name: prod-pypi + url: https://pypi.org/p/dewy permissions: id-token: write # IMPORTANT: mandatory for trusted publishing @@ -86,18 +86,20 @@ jobs: path: dist/ - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ + # with: + # repository-url: https://test.pypi.org/legacy/ - publish-dewy-client-to-test-pypi: - name: Publish dewy-client to test-pypi + publish-dewy-client-to-pypi: + name: Publish dewy-client to pypi # Only publish to PyPi on releases. - # if: github.event_name == 'release' && github.event.action == 'published' + if: github.event_name == 'release' && github.event.action == 'published' needs: build-dewy runs-on: ubuntu-latest environment: - name: test-pypi - url: https://test.pypi.org/p/dewy-client + # name: test-pypi + # url: https://test.pypi.org/p/dewy-client + name: prod-pypi + url: https://pypi.org/p/dewy-client permissions: id-token: write # IMPORTANT: mandatory for trusted publishing @@ -111,15 +113,15 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dewy-client/dist - repository-url: https://test.pypi.org/legacy/ + # repository-url: https://test.pypi.org/legacy/ github-release: name: Sign and finalize GitHub release # Only publish on release. if: github.event_name == 'release' && github.event.action == 'published' needs: - - publish-dewy-to-test-pypi - - publish-dewy-client-to-test-pypi + - publish-dewy-to-pypi + - publish-dewy-client-to-pypi runs-on: ubuntu-latest permissions: From 8955086bc13fe00dd4c9886f6f03906a24db3402 Mon Sep 17 00:00:00 2001 From: Ben Chambers <35960+bjchambers@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:54:03 -0800 Subject: [PATCH 7/7] update readme to reflect release process --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7c31197..1417445 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ To get a local copy up and running follow these steps. 1. (Optional) Start a `pgvector` instance to persist your data - Dewy uses a vector database to store metadata about the documents you've loaded as well as embeddings used to provide semantic search results. + Dewy uses a vector database to store metadata about the documents you've loaded as well as embeddings used to provide semantic search results. ```sh docker run -d \ @@ -61,7 +61,7 @@ To get a local copy up and running follow these steps. ankane/pgvector ``` If you already have an instance of `pgvector` you can create a database for Dewy and configure Dewy use it using the `DB` env var (see below). - + 1. Install Dewy ``` pip install dewy @@ -116,7 +116,7 @@ To get a local copy up and running follow these steps. ```typescript const context = await dewy.default.retrieveChunks({ collection_id: 1, - query: "tell me about RAG", + query: "tell me about RAG", n: 10, }); @@ -155,7 +155,7 @@ Don't see a feature that would make Dewy better for your application - [create a * Support more document formats (ie [Markdown](https://github.com/DewyKB/dewy/issues/29), [DOCX](https://github.com/DewyKB/dewy/issues/28), [HTML](https://github.com/DewyKB/dewy/issues/27)) * Support more types of chunk extractors -* Multi-modal search over images, tables, audio, etc. +* Multi-modal search over images, tables, audio, etc. * Integrations with LangChain, LlamaIndex, Haystack, etc. * Support flexible result ranking (ie rag-fusion, mmr, etc). * Provide metrics around which chunks are used, relevance scores, etc. @@ -219,6 +219,18 @@ If you're in a `poetry shell`, you can omit the `poetry run`: * Type Checking: `poetry run mypy app` +

(back to top)

(back to top)