From c8d0ffc59f5109635fe4e6379c28ae9018160cae Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Mon, 16 Oct 2023 09:28:41 +0000 Subject: [PATCH] ci: automatically publish to package managers --- .github/workflows/create-releases.yml | 14 ++++++++++++++ .github/workflows/publish-pypi.yml | 25 +++++++++++++++++++++++++ .github/workflows/release-doctor.yml | 1 + bin/check-release-environment | 4 ++++ release-please-config.json | 3 +++ src/anthropic_bedrock/_client.py | 12 ------------ 6 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/publish-pypi.yml diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml index f76bebb..c6f6461 100644 --- a/.github/workflows/create-releases.yml +++ b/.github/workflows/create-releases.yml @@ -18,3 +18,17 @@ jobs: with: repo: ${{ github.event.repository.full_name }} stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} + + - name: Set up Python + if: ${{ steps.release.outputs.releases_created }} + uses: actions/setup-python@v4 + with: + python-version: '3.7' + + - name: Publish to PyPI + if: ${{ steps.release.outputs.releases_created }} + run: | + pipx install poetry + bash ./bin/publish-pypi + env: + PYPI_TOKEN: ${{ secrets.ANTHROPIC_BEDROCK_PYPI_TOKEN }} diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..db986f1 --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,25 @@ +# workflow for re-running publishing to PyPI in case it fails for some reason +# you can run this workflow by navigating to https://www.github.com/anthropics/anthropic-bedrock-python/actions/workflows/publish-pypi.yml +name: Publish PyPI +on: + workflow_dispatch: + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.7' + + - name: Publish to PyPI + run: | + pipx install poetry + bash ./bin/publish-pypi + env: + PYPI_TOKEN: ${{ secrets.ANTHROPIC_BEDROCK_PYPI_TOKEN }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 744bb4a..1b99db6 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -17,3 +17,4 @@ jobs: bash ./bin/check-release-environment env: STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} + PYPI_TOKEN: ${{ secrets.ANTHROPIC_BEDROCK_PYPI_TOKEN }} diff --git a/bin/check-release-environment b/bin/check-release-environment index d639b0c..343b7a7 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -6,6 +6,10 @@ if [ -z "${STAINLESS_API_KEY}" ]; then errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organisation secrets on GitHub.") fi +if [ -z "${PYPI_TOKEN}" ]; then + errors+=("The ANTHROPIC_BEDROCK_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organisation secrets.") +fi + len=${#errors[@]} if [[ len -gt 0 ]]; then diff --git a/release-please-config.json b/release-please-config.json index 18404cc..a5a7752 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -57,6 +57,9 @@ "hidden": true } ], + "reviewers": [ + "@anthropics/sdk" + ], "release-type": "python", "extra-files": [ "src/anthropic_bedrock/_version.py" diff --git a/src/anthropic_bedrock/_client.py b/src/anthropic_bedrock/_client.py index d1bc0d2..47d2de6 100644 --- a/src/anthropic_bedrock/_client.py +++ b/src/anthropic_bedrock/_client.py @@ -81,20 +81,14 @@ def __init__( This automatically infers the `aws_region` argument from the `AWS_REGION` environment variable if it is not provided. """ - if aws_secret_key is None: - aws_secret_key = None self.aws_secret_key = aws_secret_key - if aws_access_key is None: - aws_access_key = None self.aws_access_key = aws_access_key if aws_region is None: aws_region = os.environ.get("AWS_REGION") or "us-east-1" self.aws_region = aws_region - if aws_session_token is None: - aws_session_token = None self.aws_session_token = aws_session_token if base_url is None: @@ -291,20 +285,14 @@ def __init__( This automatically infers the `aws_region` argument from the `AWS_REGION` environment variable if it is not provided. """ - if aws_secret_key is None: - aws_secret_key = None self.aws_secret_key = aws_secret_key - if aws_access_key is None: - aws_access_key = None self.aws_access_key = aws_access_key if aws_region is None: aws_region = os.environ.get("AWS_REGION") or "us-east-1" self.aws_region = aws_region - if aws_session_token is None: - aws_session_token = None self.aws_session_token = aws_session_token if base_url is None: