From bdb415e132eec862b33e15c4900825bbfef25faa Mon Sep 17 00:00:00 2001 From: fireblocks_dx_team Date: Wed, 19 Jun 2024 12:27:07 +0000 Subject: [PATCH] Generated SDK #6554 --- .bump_version.toml | 20 +++++++++++++++ .github/workflows/create-pr.yml | 33 +++++++++++++++++++++++++ .github/workflows/python-package.yml | 2 +- .github/workflows/python-publish.yml | 27 ++++++++++++++++++++ .openapi-generator/FILES | 1 + fireblocks/__init__.py | 2 +- fireblocks/api_client.py | 2 +- fireblocks/configuration.py | 2 +- fireblocks/user_agent_util.py | 3 ++- pyproject.toml | 2 +- setup.py | 2 +- test/fireblocks/test_user_agent_util.py | 9 ++++--- 12 files changed, 94 insertions(+), 11 deletions(-) create mode 100644 .bump_version.toml diff --git a/.bump_version.toml b/.bump_version.toml new file mode 100644 index 00000000..a3465f28 --- /dev/null +++ b/.bump_version.toml @@ -0,0 +1,20 @@ +[tool.bumpversion] +commit = false +tag = false +current_version = "placeholder_version" +parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)(\\-(?P[a-z]+))?" +serialize = [ + "{major}.{minor}.{patch}-{release}", + "{major}.{minor}.{patch}" +] +[[tool.bumpversion.files]] +filename = "setup.py" + +[[tool.bumpversion.files]] +filename = "pyproject.toml" + +[[tool.bumpversion.files]] +filename = "fireblocks/__init__.py" + +[[tool.bumpversion.files]] +filename = "fireblocks/configuration.py" diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml index f92a653f..1a6810e3 100644 --- a/.github/workflows/create-pr.yml +++ b/.github/workflows/create-pr.yml @@ -6,7 +6,40 @@ on: - 'fireblocks-api-spec/generated/*' jobs: + bump-version: + runs-on: ubuntu-latest + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + pip install bump-my-version + - name: Bump version + run: | + initialTag=v0.0.6 + tag="${initialTag//[v]/}" + echo $tag + git remote update + git fetch + echo "finished fetching" + echo "finished checkout" + git config --global user.email "github-actions@github.com" + git config --global user.name "Github Actions" + echo "finished configuration" + bump-my-version bump --config-file .bump_version.toml --current-version 0.0.0 --new-version $tag + echo "bumpversion finished" + git add . + git commit -m "release $tag" + git push create-pull-request: + needs: bump-version runs-on: ubuntu-latest steps: diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index facf9db2..cc084914 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: python-version: [3.8, 3.9, "3.10", 3.11, 3.12] - os: [macos-11, macos-12, windows-latest, ubuntu-20.04, ubuntu-22.04] + os: [macos-12, windows-latest, ubuntu-20.04, ubuntu-22.04] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 03935242..cc1a1ec8 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -29,6 +29,33 @@ jobs: run: | python -m pip install --upgrade pip pip install build + pip install bump-my-version + - name: Bump version + run: | + initialTag=${{ github.event.release.tag_name }} + tag="${initialTag//[v]/}" + echo $tag + git remote update + git fetch + echo "finished fetching" + git checkout --track origin/master + echo "finished checkout" + git config --global user.email "github-actions@github.com" + git config --global user.name "Github Actions" + echo "finished configuration" + bump-my-version bump --config-file .bump_version.toml --current-version 0.0.0 --new-version $tag + echo "bumpversion finished" + git add . + git commit -m "release $tag" + git push + - name: Move tag + run: | + TAG_NAME=${{ github.event.release.tag_name }} + echo $tag + git tag -d $TAG_NAME + git push origin :refs/tags/$TAG_NAME + git tag $TAG_NAME + git push origin $TAG_NAME - name: Build package run: python -m build - name: Publish package diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index b276aa49..5273c45b 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,3 +1,4 @@ +.bump_version.toml .gitignore LICENSE.txt README.md diff --git a/fireblocks/__init__.py b/fireblocks/__init__.py index c58bbeab..7678e5ef 100644 --- a/fireblocks/__init__.py +++ b/fireblocks/__init__.py @@ -15,7 +15,7 @@ """ # noqa: E501 -__version__ = "1.0.3" +__version__ = "0.0.0" # import apis into sdk package from fireblocks.api.api_user_api import ApiUserApi diff --git a/fireblocks/api_client.py b/fireblocks/api_client.py index 42dc71b0..ebc062c4 100644 --- a/fireblocks/api_client.py +++ b/fireblocks/api_client.py @@ -88,7 +88,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "OpenAPI-Generator/1.0.3/python" + self.user_agent = "fireblocks/sdk/python" self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/fireblocks/configuration.py b/fireblocks/configuration.py index c5c8608e..03f60c7b 100644 --- a/fireblocks/configuration.py +++ b/fireblocks/configuration.py @@ -424,7 +424,7 @@ def to_debug_report(self): "OS: {env}\n" "Python Version: {pyversion}\n" "Version of the API: 1.6.2\n" - "SDK Package Version: 1.0.3".format(env=sys.platform, pyversion=sys.version) + "SDK Package Version: 0.0.0".format(env=sys.platform, pyversion=sys.version) ) def get_host_settings(self): diff --git a/fireblocks/user_agent_util.py b/fireblocks/user_agent_util.py index dae9b5bb..8c839d21 100644 --- a/fireblocks/user_agent_util.py +++ b/fireblocks/user_agent_util.py @@ -11,12 +11,13 @@ """ # noqa: E501 import platform +from fireblocks import __version__ class UserAgentUtil: @staticmethod def get_user_agent(is_anonymous_platform: bool, custom_user_agent: str) -> str: - user_agent = "fireblocks/sdk/python/1.0.3" + user_agent = f"fireblocks/sdk/python/{__version__}" if not is_anonymous_platform: os_type = platform.system() os_version = platform.release() diff --git a/pyproject.toml b/pyproject.toml index 35beff34..176ccaff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fireblocks" -version = "1.0.3" +version = "0.0.0" description = "Fireblocks API" authors = ["Fireblocks "] license = "MIT License" diff --git a/setup.py b/setup.py index 560a68af..d1b349da 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools NAME = "fireblocks" -VERSION = "1.0.3" +VERSION = "0.0.0" PYTHON_REQUIRES = ">=3.8" REQUIRES = [ "urllib3 >= 1.25.3, < 2.1.0", diff --git a/test/fireblocks/test_user_agent_util.py b/test/fireblocks/test_user_agent_util.py index 17b19d8c..d2cfa328 100644 --- a/test/fireblocks/test_user_agent_util.py +++ b/test/fireblocks/test_user_agent_util.py @@ -13,6 +13,7 @@ import pytest from fireblocks.user_agent_util import UserAgentUtil +from fireblocks import __version__ @pytest.fixture def mock_platform(mocker): @@ -21,10 +22,10 @@ def mock_platform(mocker): mocker.patch('platform.machine', return_value="x86_64") @pytest.mark.parametrize("is_anonymous_platform, user_agent, expected", [ - (False, "customUserAgent", "customUserAgent fireblocks/sdk/python/1.0.3 (Linux 5.4.0-42-generic; x86_64)"), - (True, "customUserAgent", "customUserAgent fireblocks/sdk/python/1.0.3"), - (False, None, "fireblocks/sdk/python/1.0.3 (Linux 5.4.0-42-generic; x86_64)"), - (True, None, "fireblocks/sdk/python/1.0.3")]) + (False, "customUserAgent", f"customUserAgent fireblocks/sdk/python/{__version__} (Linux 5.4.0-42-generic; x86_64)"), + (True, "customUserAgent", f"customUserAgent fireblocks/sdk/python/{__version__}"), + (False, None, f"fireblocks/sdk/python/{__version__} (Linux 5.4.0-42-generic; x86_64)"), + (True, None, f"fireblocks/sdk/python/{__version__}")]) def test_get_user_agent(mock_platform, is_anonymous_platform, user_agent, expected): # Create an instance of UserAgentUtil util = UserAgentUtil()