diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55c1306a..c5cbd4da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,38 +30,3 @@ jobs: run: make run_tests - name: Upload Coverage uses: codecov/codecov-action@v4.5.0 - - publish: - needs: test - if: ${{ !startsWith(github.event.head_commit.message, 'bump') && !startsWith(github.event.head_commit.message, 'chore') && github.ref == 'refs/heads/master' && contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.repository_owner == 'supabase' }} - runs-on: ubuntu-latest - name: "Bump version, create changelog and publish" - environment: - name: pypi - url: https://pypi.org/p/postgrest - permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing - contents: write # needed for github actions bot to write to repo - steps: - - name: Clone Repository - uses: actions/checkout@v4 - with: - ref: ${{ github.ref }} - fetch-depth: 0 - token: ${{ secrets.SILENTWORKS_PAT }} - - name: Python Semantic Release - id: release - uses: python-semantic-release/python-semantic-release@v9.8.6 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - # NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true. - # See https://github.com/actions/runner/issues/1173 - if: steps.release.outputs.released == 'true' - - - name: Python Semantic Release - uses: python-semantic-release/upload-to-gh-release@main - with: - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..2c608fb3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,97 @@ +name: Release + +on: + push: + branches: + - master + workflow_dispatch: + +permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + contents: write # needed for github actions bot to write to repo + pull-requests: write + +jobs: + publish: + runs-on: ubuntu-latest + name: "Bump version, create changelog and publish" + environment: + name: pypi + url: https://pypi.org/p/postgrest + steps: + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Set up Poetry + uses: abatilo/actions-poetry@v3 + with: + poetry-version: 1.8.3 + + - uses: googleapis/release-please-action@v4 + id: release + with: + target-branch: ${{ github.ref_name }} + + - uses: actions/checkout@v4 + if: ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }} + with: + fetch-depth: 0 + + - if: ${{ steps.release.outputs }} + id: versions + run: | + set -ex + + RELEASE_CANDIDATE=true + NOT_RELEASE_CANDIDATE='${{ steps.release.outputs.release_created }}' + if [ "$NOT_RELEASE_CANDIDATE" == "true" ] + then + RELEASE_CANDIDATE=false + fi + + MAIN_RELEASE_VERSION=x + RELEASE_VERSION=y + + if [ "$RELEASE_CANDIDATE" == "true" ] + then + # Release please doesn't tell you the candidate version when it + # creates the PR, so we have to take it from the title. + MAIN_RELEASE_VERSION=$(node -e "console.log('${{ steps.release.outputs.pr && fromJSON(steps.release.outputs.pr).title }}'.split(' ').reverse().find(x => x.match(/[0-9]+[.][0-9]+[.][0-9]+/)))") + + # Use git describe tags to identify the number of commits the branch + # is ahead of the most recent non-release-candidate tag, which is + # part of the rc. value. + RELEASE_VERSION=$MAIN_RELEASE_VERSION-rc.$(node -e "console.log('$(git describe --tags --exclude rc*)'.split('-')[1])") + + # release-please only ignores releases that have a form like [A-Z0-9], so prefixing with rc + RELEASE_NAME="rc$RELEASE_VERSION" + else + MAIN_RELEASE_VERSION=${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }} + RELEASE_VERSION="$MAIN_RELEASE_VERSION" + RELEASE_NAME="v$RELEASE_VERSION" + fi + + echo "MAIN_RELEASE_VERSION=${MAIN_RELEASE_VERSION}" >> "${GITHUB_ENV}" + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_ENV}" + echo "RELEASE_CANDIDATE=${RELEASE_CANDIDATE}" >> "${GITHUB_ENV}" + echo "RELEASE_NAME=${RELEASE_NAME}" >> "${GITHUB_ENV}" + + echo "MAIN_RELEASE_VERSION=${MAIN_RELEASE_VERSION}" >> "${GITHUB_OUTPUT}" + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_OUTPUT}" + echo "RELEASE_CANDIDATE=${RELEASE_CANDIDATE}" >> "${GITHUB_OUTPUT}" + echo "RELEASE_NAME=${RELEASE_NAME}" >> "${GITHUB_OUTPUT}" + + - name: Install dependencies + run: poetry install + + - name: Build package distribution directory + id: build_dist + run: poetry build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + # NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true. + # See https://github.com/actions/runner/issues/1173 + if: ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..0ad9481d --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.16.9" +} diff --git a/postgrest/__init__.py b/postgrest/__init__.py index 04de95f2..f060e684 100644 --- a/postgrest/__init__.py +++ b/postgrest/__init__.py @@ -1,7 +1,5 @@ from __future__ import annotations -__version__ = "0.16.9" - from httpx import Timeout from ._async.client import AsyncPostgrestClient @@ -29,3 +27,4 @@ from .deprecated_client import Client, PostgrestClient from .deprecated_get_request_builder import GetRequestBuilder from .exceptions import APIError +from .version import __version__ diff --git a/postgrest/_async/client.py b/postgrest/_async/client.py index ea06eb6e..5f234a02 100644 --- a/postgrest/_async/client.py +++ b/postgrest/_async/client.py @@ -5,7 +5,6 @@ from deprecation import deprecated from httpx import Headers, QueryParams, Timeout -from .. import __version__ from ..base_client import BasePostgrestClient from ..constants import ( DEFAULT_POSTGREST_CLIENT_HEADERS, @@ -13,6 +12,7 @@ ) from ..types import CountMethod from ..utils import AsyncClient +from ..version import __version__ from .request_builder import AsyncRequestBuilder, AsyncRPCFilterRequestBuilder _TableT = Dict[str, Any] diff --git a/postgrest/_sync/client.py b/postgrest/_sync/client.py index 24f68f77..9545bf82 100644 --- a/postgrest/_sync/client.py +++ b/postgrest/_sync/client.py @@ -5,7 +5,6 @@ from deprecation import deprecated from httpx import Headers, QueryParams, Timeout -from .. import __version__ from ..base_client import BasePostgrestClient from ..constants import ( DEFAULT_POSTGREST_CLIENT_HEADERS, @@ -13,6 +12,7 @@ ) from ..types import CountMethod from ..utils import SyncClient +from ..version import __version__ from .request_builder import SyncRequestBuilder, SyncRPCFilterRequestBuilder _TableT = Dict[str, Any] diff --git a/postgrest/deprecated_client.py b/postgrest/deprecated_client.py index f66d1f8f..1d7d9722 100644 --- a/postgrest/deprecated_client.py +++ b/postgrest/deprecated_client.py @@ -2,8 +2,8 @@ from deprecation import deprecated -from . import __version__ from ._async.client import AsyncPostgrestClient +from .version import __version__ class Client(AsyncPostgrestClient): diff --git a/postgrest/deprecated_get_request_builder.py b/postgrest/deprecated_get_request_builder.py index a292274f..767cacfc 100644 --- a/postgrest/deprecated_get_request_builder.py +++ b/postgrest/deprecated_get_request_builder.py @@ -2,8 +2,8 @@ from deprecation import deprecated -from . import __version__ from ._async.request_builder import AsyncSelectRequestBuilder +from .version import __version__ class GetRequestBuilder(AsyncSelectRequestBuilder): diff --git a/postgrest/version.py b/postgrest/version.py new file mode 100644 index 00000000..3e9ca7e1 --- /dev/null +++ b/postgrest/version.py @@ -0,0 +1 @@ +__version__ = "0.16.9" # {x-release-please-version} diff --git a/pyproject.toml b/pyproject.toml index 6c462d69..f39ddeef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "postgrest" -version = "0.16.9" +version = "0.16.9" # {x-release-please-version} description = "PostgREST client for Python. This library provides an ORM interface to PostgREST." authors = ["Lương Quang Mạnh ", "Joel Lee ", "Anand", "Oliver Rice", "Andrew Smith "] homepage = "https://github.com/supabase-community/postgrest-py" diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..64661c20 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,9 @@ +{ + "last-release-sha": "9c1268e8011cf141f85cf2bbac682f86acfd06fa", + "packages": { + ".": { + "changelog-path": "CHANGELOG.md", + "release-type": "python" + } + } +}